Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 42d7e64

Browse files
committed
Merge pull request #416 from cloudspokes/SUP-214-api-stability
Sup 214 api stability
2 parents 64479e0 + 3258c14 commit 42d7e64

File tree

3 files changed

+85
-18
lines changed

3 files changed

+85
-18
lines changed

actions/tops.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ exports.getTopTrackMembers = {
516516
outputExample: {},
517517
version: 'v2',
518518
transaction: 'read',
519+
cacheLifetime: 1000 * 60 * 60 * 24,
519520
databases: ['topcoder_dw', 'tcs_dw', 'tcs_catalog'],
520521
run: function (api, connection, next) {
521522
api.log('Execute getTopTrackMembers#run', 'debug');
@@ -526,8 +527,7 @@ exports.getTopTrackMembers = {
526527
dbConnectionMap = connection.dbConnectionMap,
527528
result = {},
528529
error,
529-
sqlParams = {},
530-
isNoPaging;
530+
sqlParams = {};
531531
if (!dbConnectionMap) {
532532
helper.handleNoConnection(api, connection, next);
533533
return;
@@ -549,8 +549,7 @@ exports.getTopTrackMembers = {
549549
}
550550
if (pageIndex === -1) {
551551
pageIndex = 1;
552-
pageSize = MAX_INT; // No paging, show all.
553-
isNoPaging = true;
552+
pageSize = MAX_PAGE_SIZE; // No paging, show max allowed.
554553
}
555554
// Retrieves total number of top members for the given track.
556555
api.dataAccess.executeQuery('get_top_members_' + trackType + '_count', sqlParams, dbConnectionMap, cb);
@@ -559,10 +558,9 @@ exports.getTopTrackMembers = {
559558
cb(new Error('no rows returned from get_top_members_' + trackType + '_count'));
560559
return;
561560
}
562-
var total = rows[0].count;
563-
result.total = total;
561+
result.total = rows[0].count;
564562
result.pageIndex = pageIndex;
565-
result.pageSize = isNoPaging ? total : pageSize;
563+
result.pageSize = pageSize;
566564
result.data = [];
567565
sqlParams.firstRowIndex = (pageIndex - 1) * pageSize;
568566
sqlParams.pageSize = pageSize;

start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33

44
# nohup node ~/tc-api/node_modules/.bin/actionHero start 2>&1 &
55
#forever start -d -v -a -l "${DIR}/log/forever.log" "${DIR}/node_modules/actionhero/bin/actionhero" start
6-
forever start -d -a -l "${DIR}/log/forever.log" "${DIR}/node_modules/actionhero/bin/actionhero" startCluster --workers=2
6+
forever start -d -a -l "${DIR}/log/forever.log" "${DIR}/node_modules/actionhero/bin/actionhero" startCluster --workers=10

workers.sh

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,90 @@
22
ACTION=$1
33
SIGNAL=""
44

5+
pid=$(ps ax | grep startCluster | grep -v grep | xargs | cut -f1 -d' ')
6+
if [ "$pid" == "" ]; then
7+
echo "No cluster master process found."
8+
exit
9+
fi
10+
11+
function workers_ps {
12+
ps_out=$(ps ax | grep -- "actionhero start$" | grep -v grep)
13+
IFS='
14+
'
15+
IFS=${IFS:0:1}
16+
workers=( $ps_out )
17+
}
18+
19+
workers_ps
20+
21+
wpids=()
22+
for worker in "${workers[@]}"
23+
do
24+
wpids+=("$(echo -e "${worker}" | xargs | cut -f1 -d' ')")
25+
done
26+
27+
528
if [ "$ACTION" == "reload" ]; then
629
SIGNAL="HUP"
730
elif [ "$ACTION" == "add" ]; then
831
SIGNAL="TTIN"
932
elif [ "$ACTION" == "rm" ]; then
1033
SIGNAL="TTOU"
11-
fi
34+
elif [ "$ACTION" == "kill" ]; then
35+
for wpid in "${wpids[@]}"
36+
do
37+
kill -9 $wpid # kill the workers and let master restart
38+
done
39+
exit
40+
elif [ "$ACTION" == "recycle" ]; then
41+
numWorkers=${#wpids[@]}
42+
echo "Start Recycle, Workers Running: ${#workers[@]}"
43+
44+
for wpid in "${wpids[@]}"
45+
do
46+
kill -TTIN $pid # add one
47+
sleep 1
48+
done
1249

13-
if [ "$SIGNAL" == "" ]; then
14-
echo "Usage: workers.sh [reload|add|rm]"
50+
declare -i sleepTime
51+
sleepTime=$numWorkers
52+
sleep $sleepTime
53+
54+
workers_ps
55+
echo "Max Workers Running: ${#workers[@]}"
56+
57+
# signal recycle of all
58+
kill -HUP $pid
59+
60+
sleepTime=$numWorkers*2
61+
sleep $sleepTime
62+
63+
for wpid in "${wpids[@]}"
64+
do
65+
kill -TTOU $pid # remove one
66+
sleep 1
67+
done
68+
69+
sleepTime=$numWorkers/2
70+
sleep $sleepTime
71+
72+
workers_ps
73+
echo "End Recycle, Workers Running: ${#workers[@]}"
74+
exit
75+
elif [ "$ACTION" == "ls" ]; then
76+
for worker in "${workers[@]}"
77+
do
78+
echo -e "${worker}" | xargs | cut -f1,4 -d' '
79+
done
80+
echo "Count: ${#wpids[@]}"
81+
exit
82+
elif [ "$ACTION" == "count" ]; then
83+
echo "${#wpids[@]}"
84+
exit
1585
else
16-
pid=$(ps ax | grep startCluster | grep -v grep | xargs | cut -f1 -d' ')
17-
if [ "$pid" == "" ]; then echo "No cluster master process found."
18-
else
19-
kill -$SIGNAL $pid
20-
echo "Signal $SIGNAL sent to process: $pid"
21-
fi
22-
fi
86+
echo "Usage: workers.sh [reload|recycle|add|rm|ls|count]"
87+
exit
88+
fi
89+
90+
kill -$SIGNAL $pid
91+
echo "Signal $SIGNAL sent to process: $pid"

0 commit comments

Comments
 (0)