[web2py] restart web2py command line

598 views
Skip to first unread message

Avik Basu

unread,
Apr 29, 2010, 1:30:00 PM4/29/10
to web2py-users
Hi,
Is there a way to restart web2py from the command line in a linux
environment?
Avik

Thadeus Burgess

unread,
Apr 29, 2010, 2:00:59 PM4/29/10
to web...@googlegroups.com
How are you running web2py?

If I need to kill a web2py process that I started from the command
line, but lost its process id I do the following command

$: ps aux | grep web2py
tburgess 12854 0.0 0.5 394812 62296 ? Sl 11:24 0:04
/usr/bin/python2.6 -u /home/tburgess/Applications/web2py/web2py.py -a
asdf
$: kill 12854

Sometimes web2py will hang and will not shut down, so you might have
to pass the -9 flag if it is still running after a minute or two.

$: kill -9 12854


--
Thadeus

Iceberg

unread,
Apr 29, 2010, 2:35:49 PM4/29/10
to web2py-users
FYI: Usually the process id exists in /path_of_web2py/httpserver.pid

Yarko Tymciurak

unread,
Apr 29, 2010, 3:34:44 PM4/29/10
to web2py-users
It depends - if you are running from mod_wsgi, then web2py might be a
thread - there is a file to "touch" for mod_wsgi to restart that
thread... how you are running it (how you started it) is really the
critical question.

Jonathan Lundell

unread,
Apr 29, 2010, 4:01:04 PM4/29/10
to web...@googlegroups.com
On Apr 29, 2010, at 10:30 AM, Avik Basu wrote:

> Is there a way to restart web2py from the command line in a linux
> environment?

I adapted one of the startup scripts in scripts/ (I think I started with the Fedora one) to make a shell script that I use from the command line. It'd be easy enough to add a 'restart' case that combines stop & start.

#!/bin/sh
#
# start web2py with recycled password and no tk UI
# -N disables cron
#
W2PDIR=path-to-web2py
PIDFILE=httpserver.pid
SCRIPT=`basename $0`
PORT=8000
PW=admin-password

if [ "$1" == first ]; then
echo $W2PDIR/web2py -p $PORT -a $PW
(python $W2PDIR/web2py.py -p $PORT -N -a $PW) &
echo
echo vpepm started
elif [ "$1" == start ]; then
echo $W2PDIR/web2py -p $PORT -a "<recycle>"
(python $W2PDIR/web2py.py -p $PORT -N -a "<recycle>") &
echo
echo vpepm started
elif [ "$1" == stop ]; then
if [ ! -r $W2PDIR/$PIDFILE ]; then
echo pid file $PIDFILE not found
exit 1
fi
PID=`cat $W2PDIR/$PIDFILE`
rm -f $W2PDIR/$PIDFILE
kill -TERM $PID
echo vpepm stopped
else
echo "usage: $SCRIPT start|stop"
exit 1
fi
exit 0

Reply all
Reply to author
Forward
0 new messages