On 27/04/11 06:33, Mike Orr wrote:
I run my apps under supervisor, which is a Python daemon manager.

On Tue, Apr 26, 2011 at 3:26 PM, Krishnakant Mane<[email protected]>  wrote:
Hello all.
I have a pylons application running in a virtual environment.
Can some one give me a hint as to how I could have the virtual environment
started and the paster serve production.ini be run as a daemon?

I looked on the internet and found one shell script.
I am paisting the content below but not sure if that shell script
initialises the venv.

#! /bin/sh

### BEGIN INIT INFO
# Provides:<my_app>  application instance
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of<my_app>  app
# Description:       starts instance of<my app>  app using start-stop-daemon
### END INIT INFO

############### EDIT ME ##################
# path to workingenv install if any
PYTHONPATH=<path to pylons workingenv>/lib/python2.4

# path to app
APP_PATH=<path to my_app>

# path to paster bin
DAEMON=<path to pylons workingenv>/bin/paster

# startup args
DAEMON_OPTS=" serve --log-file<my logfile>  --server-name=main
production.ini"

# script name
NAME=<my_rc_script.sh>

# app name
DESC=<my_app>

# pylons user
RUN_AS=<user to switch to after startup>

PID_FILE=/var/run/paster.pid

############### END EDIT ME ##################

test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background
--pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --pidfile $PID_FILE
        echo "$NAME."
        ;;

  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --pidfile $PID_FILE
        sleep 1
        start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background
--pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}">&2
        exit 1
        ;;
esac

exit 0

Can this be a more simpler thing than what I paisted?
I did not understand the opts that were passed to the daemon.
I can figure out production.ini but why the other one?

happy hacking.
Krishnakant.

--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.




I would also like to use superwiser.
Can you give some hint?
By the way I think I must make a daemon any ways because I have to make an automated system where my application is started as a background process as soon as the machine starts. So I don't expect the end user to do a paster serve --daemonise production.ini manuall.
Can this too be automated?
And yes there is also this step of starting the virtual environment which should also be automated.
I guess this certainly need some kind of a shell script?
Happy hacking.
Krishnakant.


--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to