Skip to content
Newer
Older
100755 84 lines (75 sloc) 1.73 KB
b737b73 @wraithan pelican!
authored Sep 21, 2012
1 #!/bin/bash
2 ##
3 # This section should match your Makefile
4 ##
5 PELICAN=pelican
6 PELICANOPTS=
7
8 BASEDIR=$(PWD)
9 INPUTDIR=$BASEDIR/content
10 OUTPUTDIR=$BASEDIR/output
11 CONFFILE=$BASEDIR/pelicanconf.py
12
13 ###
14 # Don't change stuff below here unless you are sure
15 ###
16
17 SRV_PID=$BASEDIR/srv.pid
18 PELICAN_PID=$BASEDIR/pelican.pid
19
20 function usage(){
21 echo "usage: $0 (stop) (start) (restart)"
22 echo "This starts pelican in debug and reload mode and then launches"
23 echo "A SimpleHTTP server to help site development. It doesn't read"
24 echo "your pelican options so you edit any paths in your Makefile"
25 echo "you will need to edit it as well"
26 exit 3
27 }
28
29 function shut_down(){
30 if [[ -f $SRV_PID ]]; then
31 PID=$(cat $SRV_PID)
32 PROCESS=$(ps -p $PID | tail -n 1 | awk '{print $4}')
33 if [[ $PROCESS == python ]]; then
34 echo "Killing SimpleHTTPServer"
35 kill $PID
36 else
37 echo "Stale PID, deleting"
38 fi
39 rm $SRV_PID
40 else
41 echo "SimpleHTTPServer PIDFile not found"
42 fi
43
44 if [[ -f $PELICAN_PID ]]; then
45 PID=$(cat $PELICAN_PID)
46 PROCESS=$(ps -p $PID | tail -n 1 | awk '{print $4}')
47 if [[ $PROCESS != "" ]]; then
48 echo "Killing Pelican"
49 kill $PID
50 else
51 echo "Stale PID, deleting"
52 fi
53 rm $PELICAN_PID
54 else
55 echo "Pelican PIDFile not found"
56 fi
57 }
58
59 function start_up(){
60 echo "Starting up Pelican and SimpleHTTPServer"
61 shift
62 $PELICAN --debug --autoreload -r $INPUTDIR -o $OUTPUTDIR -s $CONFFILE $PELICANOPTS &
63 echo $! > $PELICAN_PID
64 cd $OUTPUTDIR
65 python -m SimpleHTTPServer &
66 echo $! > $SRV_PID
67 cd $BASEDIR
68 }
69
70 ###
71 # MAIN
72 ###
73 [[ $# -ne 1 ]] && usage
74 if [[ $1 == "stop" ]]; then
75 shut_down
76 elif [[ $1 == "restart" ]]; then
77 shut_down
78 start_up
79 elif [[ $1 == "start" ]]; then
80 start_up
81 else
82 usage
83 fi
Something went wrong with that request. Please try again.