Skip to content

Commit d87a2ae

Browse files
authored
Merge pull request #129 from dom-jiang/main
add pool tasks
2 parents 5968086 + bc94bcf commit d87a2ae

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
pid=`ps -ef | grep "update_pools.py [NETWORK_ID] 5000" | grep -v grep | /usr/bin/awk '{print $2}'`
4+
5+
cd "[CUR_PATH]"
6+
7+
# echo ${pid}
8+
date >> backend_update_pools.log
9+
10+
if [ ! ${pid} ]; then
11+
# echo "is null"
12+
echo "No backend process rubbish to clean." >> backend_update_pools.log
13+
else
14+
# echo "not null"
15+
kill -s 9 ${pid}
16+
echo "Warning: clean backend process of last round." >> backend_update_pools.log
17+
fi
18+
. ../venv/bin/activate
19+
python update_pools.py [NETWORK_ID] 5000 >> backend_update_pools.log
20+
echo 'OK'
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
sys.path.append('../')
3+
from config import Cfg
4+
5+
if __name__ == '__main__':
6+
cur_path = sys.path[0]
7+
print("Working Path is:", cur_path)
8+
9+
network_id = Cfg.NETWORK_ID
10+
11+
exec_lines = []
12+
tmpl = open("%s/backend_update_pools_5.sh.tmpl" % cur_path, mode='r')
13+
while True:
14+
line = tmpl.readline()
15+
if not line:
16+
break
17+
exec_lines.append(line.replace("[CUR_PATH]", cur_path).replace("[NETWORK_ID]", network_id))
18+
tmpl.close()
19+
20+
target_file = open("%s/backend_update_pools_5.sh" % cur_path, mode='w')
21+
target_file.writelines(exec_lines)
22+
target_file.close()
23+
24+
print("Note: backend_update_pools_5.sh should be generated at that Path, ")
25+
print("please make it excuteable, such as chmod a+x backend_update_pools_5.sh. ")
26+
print("and then put it into crontab for periodically invoke!")
27+
print("Crontab eg: ")
28+
print(" */1 * * * * /working_path/backend_update_pools_5.sh > /dev/null")
29+

0 commit comments

Comments
 (0)