-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphantomjs
executable file
·49 lines (44 loc) · 969 Bytes
/
phantomjs
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
#!/bin/bash
# Put this script into /etc/init.d for using phantomhs as service
PHANTOMJS=/usr/bin/phantomjs
PHANTOMJSARGS="--webdriver=4444"
PHANTOMJSLOG="/var/log/phantomjs.log"
PHANTOMJSERRORLOG="/var/log/phantomjs-error.log"
PID=`ps -ef | grep $PHANTOMJS | grep -v grep | awk '{ print $2 }'`
case "$1" in
start)
if [ -z "$PID" ]
then
`$PHANTOMJS $PHANTOMJSARGS > $PHANTOMJSLOG 2> $PHANTOMJSERRORLOG &`
echo "PhantomJS is started."
else
echo "PhantomJS is running. PID: $PID"
fi
;;
stop)
if [ -z "$PID" ]
then
echo "PhantomJS is not running"
else
kill $PID
echo "PhantomJS stopped."
fi
;;
restart)
$0 stop
sleep 2s
$0 start
;;
status)
if [ -z "$PID" ]
then
echo "PhantomJS is not running"
else
echo "PhantomJS is running. PID: $PID"
fi
;;
*)
echo "Usage: /etc/init.d/phantomjs {start|stop|restart|status}"
exit 1
esac
exit 0