Startup script for Radiant with Mongrel
Posted by Paul Verreth Mon, 26 Mar 2007 05:54:00 GMT
Mongrel is IMHO the preferred (web)server for Ruby on Rails applications hence for Radiant.
Here you can find a startup script for Fedora linux, but of course also usable for Ubuntu, ...
#!/bin/bash
#
# /etc/rc.d/init.d/radiant_cms
#
# Start mongrel & radiant
#
# chkconfig: - 65 35
# description: Mongrel & radiant
# processname: mongrel
# Source function library.
. /etc/init.d/functions
MONGREL=/usr/bin/mongrel_rails
RAILSDIR=/var/www/radiant
CONFFILE=mongrel_config
test -x $MONGREL || exit 0
RETVAL=0
prog="Mongrel for radiant"
start() {
echo -n $"Starting $prog: "
cd $RAILSDIR
$MONGREL start -C $CONFFILE
RETVAL=$?
echo
}
stop() {
echo -n $"Stopping $prog: "
cd $RAILSDIR
$MONGREL stop
RETVAL=$?
echo
}
#
# See how we were called.
#
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
mongrel_config
--- :cwd: /var/www/radiant :includes: - mongrel :debug: false :log_file: log/mongrel.log :config_script: :pid_file: log/mongrel.pid :timeout: 0 :num_processors: 1024 :docroot: public :config_file: :user: apache :host: 0.0.0.0 :group: apache :mime_map: :environment: production :prefix: :port: 4000 :daemon: true
This file should be fairly self explaining:
/var/www/radiantis the radiant base directory.- host: 0.0.0.0 listens on every address, for safety better to use 127.0.0.1, and in combination with reverse proxying
- port: 4000 for instance for reverse proxying, 80 for direct web serving.
mongrel with apache as a reverse proxy will be explained in a different article to come.
chkconfig
On fedora you can use chkconfig to activate the startup script. Please also read the chkconfig man page.
#!/bin/bash # # /etc/rc.d/init.d/radiant_cms # # Start mongrel & radiant # # chkconfig: - 65 35 # description: Mongrel & radiant # processname: mongrelActive? And in wich runlevels?
chkconfig --list radiant_cms service radiant_cms supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add radiant_cms')So it is added, but not yet activated:
chkconfig --add radiant_cms chkconfig --list radiant_cms radiant_cms 0:off 1:off 2:off 3:off 4:off 5:off 6:off
And, to activate:
chkconfig radiant_cms on chkconfig --list radiant_cms 0:off 1:off 2:on 3:on 4:on 5:on 6:off

