-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy patharchive.sh
More file actions
60 lines (59 loc) · 974 Bytes
/
archive.sh
File metadata and controls
60 lines (59 loc) · 974 Bytes
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
51
52
53
54
55
56
57
58
59
60
LOCK='archive.lock'
start()
{
if [ "$(is_running)" != "1" ]; then
printf "Starting archive service...\n";
nohup php artisan facebook:index service &> archive.log&
echo $! > $LOCK
else
printf "Already running...\n";
fi
status
}
stop()
{
if [ -f $LOCK ]; then
printf "Stopping... \n";
kill -9 $(cat $LOCK)
rm -f $LOCK
printf "Stopped!\n";
fi
}
status()
{
PID=$(cat $LOCK)
running=$(is_running)
if [ "$running" = "1" ]; then
printf "\033[0;32mRunning: $PID\033[0m\n"
elif [ "$running" = "-1" ]; then
printf "\033[0;33mProcess exists in lock file but not running\033[0m\n"
else
printf "\033[0;33mNot running\033[0m\n"
fi
}
is_running(){
local result
if [ -f $LOCK ]; then
local PID=$(cat $LOCK)
if ps -p $PID > /dev/null
then
result=1;
else
result=-1
fi
else
result=0
fi
echo $result;
}
CMD=$1;
if [ "$1" = "stop" ]; then
stop
elif [ "$1" = "start" ]; then
start
elif [ "$1" = "restart" ]; then
stop
start
else
status
fi