Skip to content

Instantly share code, notes, and snippets.

@mwalling
Created June 2, 2009 22:01
Show Gist options
  • Save mwalling/122625 to your computer and use it in GitHub Desktop.
Save mwalling/122625 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo 0: $0
dirname $0
mwalling@you ~/test$ bash ~/test/test.sh
0: /home/mwalling/test/test.sh
/home/mwalling/test
mwalling@you ~/test$ bash test.sh
0: test.sh
.
#!/bin/sh
# vim:nospell
PROJECTROOT="$(dirname $0)" # This is what "dont work". Its normally manually set to the project root
PIDFILE=$PROJECTROOT/../fcgi.pid
SOCKET=$PROJECTROOT/../fcgi.sock
function stop {
cd $PROJECTROOT
kill $( cat $PIDFILE )
}
function start {
manage.py runfcgi \
socket=$SOCKET \
daemonize=true \
pidfile=$PIDFILE
chmod a+w $SOCKET
}
if [ x$1 == x ]
then
CMD="restart"
else
CMD=$1
fi
case $CMD in
start)
start;;
stop)
stop;;
restart)
stop
start;;
esac
mwalling@you /home/wwwdata/usercomments.dontlike.us/usercomments$ restartserver.sh
cat: ./../fcgi.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
chmod: cannot access `./../fcgi.sock': No such file or directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment