-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
executable file
·50 lines (44 loc) · 1.13 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8
from spider.common import *
import time
import os
import sys
def start():
if os.path.isfile(PID_FILE):
f=open(PID_FILE,'r')
pid=f.read()
print "Spider Is Running .... PID %s" % pid
f.close()
return 0
os.system( "$(which python) spider/spider.py")
time.sleep(2)
if os.path.isfile(PID_FILE):
f=open(PID_FILE,'r')
pid=f.read()
print "Spider Started .... PID %s" % pid
return 0
print "Spider Start Filed .... "
def stop():
if os.path.isfile(PID_FILE):
f=open(PID_FILE,'r')
pid=f.read()
os.system("kill -9 %s" % pid)
os.remove(PID_FILE)
print "Spider Stoped .... "
return 0
print "Spider Is Not Running .... "
def status():
if os.path.isfile(PID_FILE):
f=open(PID_FILE,'r')
pid=f.read()
print "Spider Is Running .... PID %s" % pid
return 0
print "Spider Is Not Running .... "
def helps():
print "Usage: python %s start|stop|status" % sys.argv[0]
server={"start":start,"stop":stop,"status":status,"helps":helps}
if len(sys.argv) != 2 or sys.argv[1] not in server.keys():
server["helps"]()
sys.exit(1)
par=sys.argv[1]
server[par]()