<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Starting and Stopping an OpenACS instance.</title><meta name="generator" content="DocBook XSL Stylesheets V1.66.1"><link rel="home" href="index.html" title="OpenACS Core Documentation"><link rel="up" href="maintenance-web.html" title="Chapter�6.�Production Environments"><link rel="previous" href="maintenance-web.html" title="Chapter�6.�Production Environments"><link rel="next" href="install-openacs-inittab.html" title="AOLserver keepalive with inittab"><link rel="stylesheet" href="openacs.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><a href="http://openacs.org"><img src="/doc/images/alex.jpg" border="0" alt="Alex logo"></a><table width="100%" summary="Navigation header" border="0"><tr><td width="20%" align="left"><a accesskey="p" href="maintenance-web.html">Prev</a> </td><th width="60%" align="center">Chapter�6.�Production Environments</th><td width="20%" align="right"> <a accesskey="n" href="install-openacs-inittab.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="install-openacs-keepalive"></a>Starting and Stopping an OpenACS instance.</h2></div></div></div><p>The simplest way to start and stop and OpenACS site is to run the startup shell script provided, <tt class="computeroutput">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/etc/daemontools/run</tt>. This runs as a regular task, and logs to the logfile. To stop the site, kill the script.</p><p>A more stable way to run OpenACS is with a "keepalive" mechanism of some sort, so that whenever the server halts or is stopped for a reset, it restarts automatically. This is recommended for development and production servers.</p><p>The Reference Platform uses Daemontools to control AOLserver. A simpler method, using <tt class="computeroutput">init</tt>, is <a href="install-openacs-inittab.html" title="AOLserver keepalive with inittab">here</a>.</p><div class="orderedlist"><ol type="1"><li><p>Daemontools must already be installed. If not, <a href="install-daemontools.html" title="Install Daemontools (OPTIONAL)">install it</a>.</p></li><li><p>Each service controlled by daemontools must have a directory in <tt class="computeroutput">/service</tt>. That directory must have a file called <tt class="computeroutput">run</tt>. It works like this:</p><div class="itemizedlist"><ul type="disc"><li><p>The <tt class="computeroutput">init</tt> program starts every time the computer is booted. </p></li><li><p>A line in <tt class="computeroutput">init</tt>'s configuration file, <tt class="computeroutput">/etc/inittab</tt>, tells init to run, and to restart if necessary, <tt class="computeroutput">svscanboot</tt>.</p></li><li><p><tt class="computeroutput">svscanboot</tt> checks the directory <tt class="computeroutput">/service</tt> every few seconds.</p></li><li><p>If it sees a subdirectory there, it looks for a file in the subdirectory called <tt class="computeroutput">run</tt>. If it finds a run file, it creates a <tt class="computeroutput">supervise</tt> process</p></li><li><p><tt class="computeroutput">supervise </tt> executes the run script. Whenever the run script stops, <tt class="computeroutput">supervise</tt> executes it again. It also creates additional control files in the same directory. </p></li></ul></div><p>Hence, the AOLserver instance for your development server is started by the file <tt class="computeroutput">/service/$OPENACS_SERVICE_NAME/run</tt>. But we use a symlink to make it easier to add and remove stuff from the <tt class="computeroutput">/service</tt>, so the actual location is <tt class="computeroutput">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>etc/daemontools/run</tt>.</p><p>Daemontools creates additional files and directories to track status and log. A daemontools directory is included in the OpenACS tarball at <tt class="computeroutput">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/etc/daemontools</tt>. To use it, first ill any existing AOLserver instances. As root, link the <tt class="computeroutput">daemontools</tt> directory into the <tt class="computeroutput">/service</tt> directory. Daemontools' <tt class="computeroutput">svscan</tt> process checks this directory every five seconds, and will quickly execute <tt class="computeroutput">run</tt>.</p><pre class="screen">[$OPENACS_SERVICE_NAME etc]$ <b class="userinput"><tt>killall nsd</tt></b> nsd: no process killed [$OPENACS_SERVICE_NAME etc]$ <b class="userinput"><tt>emacs /var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/etc/daemontools/run</tt></b> [$OPENACS_SERVICE_NAME etc]$ <b class="userinput"><tt>exit</tt></b> [root root]# <b class="userinput"><tt>ln -s /var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/etc/daemontools/ /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt></b></pre><p>Verify that AOLserver is running.</p><pre class="screen">[root root]#<b class="userinput"><tt> ps -auxw | grep nsd</tt></b> <span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span> 5562 14.2 6.2 22436 15952 ? S 11:55 0:04 /usr/local/aolserver/bin/nsd -it /var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/etc/config.tcl -u serve root 5582 0.0 0.2 3276 628 pts/0 S 11:55 0:00 grep nsd [root root]#</pre></li><li><p>The user <span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span> can now control the service <span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span> with these commands:</p><div class="itemizedlist"><ul type="disc"><li><p> <tt class="computeroutput">svc -d /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt> - Bring the server down </p></li><li><p> <tt class="computeroutput">svc -u /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt> - Start the server up and leave it in keepalive mode. </p></li><li><p> <tt class="computeroutput">svc -o /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt> - Start the server up once. Do not restart it if it stops. </p></li><li><p> <tt class="computeroutput">svc -t /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt> - Stop and immediately restart the server. </p></li><li><p> <tt class="computeroutput">svc -k /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt> - Sends the server a KILL signal. This is like KILL -9. AOLserver exits immediately. If svc -t fails to fully kill AOLserver, use this option. This does not take the server out of keepalive mode, so it should still bounce back up immediately. </p></li></ul></div></li><li><p>Install a script to automate the stopping and starting of AOLserver services via daemontools. You can then restart a service via <tt class="computeroutput">restart-aolserver <span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt></p><pre class="screen">[root root]# <b class="userinput"><tt>cp /var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/packages/acs-core-docs/www/files/restart-aolserver-daemontools.txt /usr/local/bin/restart-aolserver</tt></b> [root root]# <b class="userinput"><tt>chmod 755 /usr/local/bin/restart-aolserver</tt></b> [root root]#</pre></li><li><p> At this point, these commands will work only for the <tt class="computeroutput">root</tt> user. Grant permission for the <tt class="computeroutput">web</tt> group to use <tt class="computeroutput">svc</tt> commands on the <span class="emphasis"><em><span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></em></span> server.</p><pre class="screen">[root root]# <b class="userinput"><tt>/usr/local/bin/svgroup web /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></tt></b> [root root]#</pre></li><li><p>Verify that the controls work. You may want to <tt class="computeroutput">tail -f /var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/log/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>-error.log</tt> in another window, so you can see what happens when you type these commands. </p><p> Most of this information comes from Tom Jackson's <a href="http://zmbh.com/daemontools-aolserver/aolserver+daemontools.html" target="_top">AOLserver+Daemontools Mini-HOWTO</a>. </p></li></ol></div><div class="table"><a name="id2541639"></a><p class="title"><b>Table�6.1.�How it Works</b></p><table summary="How it Works" cellspacing="0" border="1"><colgroup><col><col><col><col><col><col></colgroup><thead><tr><th align="center">Program</th><th align="center">Invoked by this program ...</th><th align="center">... using this file</th><th align="center">Where to find errors</th><th align="center">Log goes to</th><th align="center">Use these commands to control it</th></tr></thead><tbody><tr><td align="center">svscanboot </td><td align="center">init</td><td align="center">/etc/inittab</td><td align="center">ps -auxw | grep readproctitle</td><td align="center">n/a</td><td align="center">�</td></tr><tr><td align="center">aolserver</td><td align="center"><tt class="computeroutput"></tt>supervise (a child of svscanboot)</td><td align="center">/service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/run</td><td align="center">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/log/error.log</td><td align="center">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span>/log/$OPENACS_SERVICE_NAME.log</td><td align="center">svc -k /service/<span class="replaceable"><span class="replaceable">$OPENACS_SERVICE_NAME</span></span></td></tr><tr><td align="center">postgresql</td><td align="center">Redhat init scripts during boot</td><td align="center">/etc/init.d/postgresql</td><td align="center">/usr/local/pgsql/data/server.log</td><td align="center">�</td><td align="center">service postgresql start (Red Hat), /etc/init.d/postgresql start (Debian)</td></tr></tbody></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="maintenance-web.html">Prev</a> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right"> <a accesskey="n" href="install-openacs-inittab.html">Next</a></td></tr><tr><td width="40%" align="left">Chapter�6.�Production Environments </td><td width="20%" align="center"><a accesskey="u" href="maintenance-web.html">Up</a></td><td width="40%" align="right"> AOLserver keepalive with inittab</td></tr></table><hr><address><a href="mailto:docs@openacs.org">docs@openacs.org</a></address></div><a name="comments"></a><center><a href="http://openacs.org/doc/current/install-openacs-keepalive.html#comments">View comments on this page at openacs.org</a></center></body></html>