@@ -28,55 +28,55 @@ function usage(){
28
28
}
29
29
30
30
function alive() {
31
- kill -0 $1 > /dev/null 2>&1
31
+ kill -0 " $1 " > /dev/null 2>&1
32
32
}
33
33
34
34
function shut_down(){
35
- PID=$( cat $SRV_PID )
36
- if [[ $? -eq 0 ]]; then
37
- if alive $PID ; then
35
+ PID=$( cat " $SRV_PID " )
36
+ if [ -z " $PID " ]; then
37
+ echo " HTTP server PIDFile not found"
38
+ else
39
+ if alive " $PID " ; then
38
40
echo " Stopping HTTP server"
39
- kill $PID
41
+ kill " $PID "
40
42
else
41
43
echo " Stale PID, deleting"
42
44
fi
43
- rm $SRV_PID
44
- else
45
- echo " HTTP server PIDFile not found"
45
+ rm " $SRV_PID "
46
46
fi
47
47
48
- PID=$( cat $PELICAN_PID )
49
- if [[ $? -eq 0 ]]; then
50
- if alive $PID ; then
48
+ PID=$( cat " $PELICAN_PID " )
49
+ if [ -z " $PID " ]; then
50
+ echo " Pelican PIDFile not found"
51
+ else
52
+ if alive " $PID " ; then
51
53
echo " Killing Pelican"
52
- kill $PID
54
+ kill " $PID "
53
55
else
54
56
echo " Stale PID, deleting"
55
57
fi
56
- rm $PELICAN_PID
57
- else
58
- echo " Pelican PIDFile not found"
58
+ rm " $PELICAN_PID "
59
59
fi
60
60
}
61
61
62
62
function start_up(){
63
63
local port=$1
64
64
echo " Starting up Pelican and HTTP server"
65
65
shift
66
- $PELICAN --debug --autoreload -r $INPUTDIR -o $OUTPUTDIR -s $CONFFILE $PELICANOPTS &
66
+ $PELICAN --debug --autoreload -r " $INPUTDIR " -o " $OUTPUTDIR " -s " $CONFFILE " " $PELICANOPTS " &
67
67
pelican_pid=$!
68
- echo $pelican_pid > $PELICAN_PID
69
- mkdir -p $OUTPUTDIR && cd $OUTPUTDIR
70
- $PY -m pelican.server $port &
68
+ echo $pelican_pid > " $PELICAN_PID "
69
+ mkdir -p " $OUTPUTDIR " && " cd $OUTPUTDIR " || exit
70
+ $PY -m pelican.server " $port " &
71
71
srv_pid=$!
72
- echo $srv_pid > $SRV_PID
73
- cd $BASEDIR
72
+ echo $srv_pid > " $SRV_PID "
73
+ cd " $BASEDIR " || exit
74
74
sleep 1
75
75
if ! alive $pelican_pid ; then
76
76
echo " Pelican didn't start. Is the Pelican package installed?"
77
77
return 1
78
78
elif ! alive $srv_pid ; then
79
- echo " The HTTP server didn't start. Is there another service using port" $port " ?"
79
+ echo " The HTTP server didn't start. Is there another service using port $port ?"
80
80
return 1
81
81
fi
82
82
echo ' Pelican and HTTP server processes now running in background.'
@@ -94,9 +94,9 @@ if [[ $1 == "stop" ]]; then
94
94
shut_down
95
95
elif [[ $1 == " restart" ]]; then
96
96
shut_down
97
- start_up $port
97
+ start_up " $port "
98
98
elif [[ $1 == " start" ]]; then
99
- if ! start_up $port ; then
99
+ if ! start_up " $port " ; then
100
100
shut_down
101
101
fi
102
102
else
0 commit comments