<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Supporting Open Source weblog: Startup script for Radiant with Mongrel</title>
    <link>http://blog.sos.be/articles/2007/03/26/startup-script-for-radiant-with-mongrel</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Startup script for Radiant with Mongrel</title>
      <description>&lt;p&gt;&lt;a href="http://mongrel.rubyforge.org/index.html"&gt;Mongrel&lt;/a&gt; is &lt;span class="caps"&gt;IMHO&lt;/span&gt; the preferred (web)server for &lt;em&gt;Ruby on Rails&lt;/em&gt; applications hence for &lt;a href="http://www.radiantcms.org"&gt;Radiant&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Here you can find a startup script for Fedora linux, but of course also usable for Ubuntu, ...&lt;/p&gt;


&lt;pre&gt;
#!/bin/bash
#
#    /etc/rc.d/init.d/radiant_cms
#
# Start mongrel &amp;#38; radiant
#
# chkconfig: - 65 35
# description: Mongrel &amp;#38; 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
&lt;/pre&gt;&lt;h4&gt;mongrel_config&lt;/h4&gt;


&lt;pre&gt;
--- 
: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
&lt;/pre&gt;

	&lt;p&gt;This file should be fairly self explaining:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;code&gt;/var/www/radiant&lt;/code&gt; is the &lt;strong&gt;radiant&lt;/strong&gt; base directory.&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;host:&lt;/em&gt; 0.0.0.0 listens on every address, for safety better to use 127.0.0.1, and in combination with reverse proxying&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;port:&lt;/em&gt; 4000 for instance for reverse proxying, 80 for direct web serving.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;strong&gt;mongrel&lt;/strong&gt; with &lt;em&gt;apache&lt;/em&gt; as a &lt;em&gt;reverse proxy&lt;/em&gt; will be explained in a different article to come.&lt;/p&gt;


	&lt;h3&gt;chkconfig&lt;/h3&gt;


	&lt;p&gt;On fedora you can use &lt;code&gt;chkconfig&lt;/code&gt; to activate the startup script. Please also read the &lt;code&gt;chkconfig&lt;/code&gt; man page.&lt;/p&gt;


To be manageable by chkconfig, the script needs a special section, an example follows:
&lt;pre&gt;
#!/bin/bash
#
#    /etc/rc.d/init.d/radiant_cms
#
# Start mongrel &amp;#38; radiant
#
# chkconfig: - 65 35
# description: Mongrel &amp;#38; radiant
# processname: mongrel
&lt;/pre&gt;

Active? And in wich runlevels?
&lt;pre&gt;
chkconfig --list radiant_cms
service radiant_cms supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add radiant_cms')
&lt;/pre&gt;

So it is added, but not yet activated:
&lt;pre&gt;
chkconfig --add radiant_cms
chkconfig --list radiant_cms
radiant_cms        0:off   1:off   2:off   3:off   4:off   5:off   6:off
&lt;/pre&gt;

	&lt;p&gt;And, to activate:&lt;/p&gt;


&lt;pre&gt;
chkconfig radiant_cms on

chkconfig --list 
radiant_cms        0:off   1:off   2:on    3:on    4:on    5:on    6:off
&lt;/pre&gt;</description>
      <pubDate>Mon, 26 Mar 2007 07:54:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:242c52db-a14e-450d-9c68-ce3a080c1962</guid>
      <author>Paul Verreth</author>
      <link>http://blog.sos.be/articles/2007/03/26/startup-script-for-radiant-with-mongrel</link>
      <category>artikels</category>
      <category>interessant open source</category>
      <category>mongrel</category>
      <category>radiant</category>
    </item>
  </channel>
</rss>
