Thanks for your kind help Sebastian.<br>Following your instructions, I have managed to write init script for start and stop. I was lucky to get code from <a href="http://www.nabble.com/attachment/8445249/1/squeak_http_service">http://www.nabble.com/attachment/8445249/1/squeak_http_service</a><br>
<br>and after some tweaking, I have the following code for /etc/init.d/seaside<br><br>#########################################################################<br>#!/bin/sh<br><br># Script to start a Squeak(Seaside) Image which runs Kom HTTP Server in -nodisplay mode.<br>
# Because main purpose is to run as service from /etc/init.d/seaside,<br># this can be started by root, but runs under regular user<br><br># Check and run what user asked for.<br><br>case &quot;$1&quot; in<br>&nbsp;&nbsp;&nbsp; start)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo -n &quot;Starting Seaside &quot;<br>&nbsp;&nbsp;&nbsp; if [ &quot;$SQUEAK_HTTP_PID&quot; != &quot;&quot; ]; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; echo &quot;SQUEAK_HTTP Already running, exiting&quot;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; # exit 1<br>&nbsp;&nbsp;&nbsp; else<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; # Change directory and run Squeak headless<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; cd /home/rajeev/caartz<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /usr/bin/squeakvm -nodisplay caartz01 &quot;&quot; port 9091 &amp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQUEAK_HTTP_PID=`ps -eo pid,command | grep &quot;squeak&quot; | grep -v grep | awk &#39;{ print $1 }&#39;`<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd /var/run<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; echo &quot;Seaside is Started and is running with PID&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $SQUEAK_HTTP_PID<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $SQUEAK_HTTP_PID &gt; squeak.pid<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br>
&nbsp;&nbsp;&nbsp; stop)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo -n &quot;Shutting down Seaside &quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd /var/run&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQUEAK_HTTP_PID=`head squeak.pid` <br>&nbsp;&nbsp;&nbsp; if [ &quot;$SQUEAK_HTTP_PID&quot; = &quot;&quot; ]; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; echo &quot;Seaside Not running!&quot;<br>
&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; #kill -SIGINT $SQUEAK_HTTP_PID<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; kill -HUP $SQUEAK_HTTP_PID<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rm -rf squeak.pid<br>&nbsp;&nbsp;&nbsp; fi<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br>&nbsp;&nbsp;&nbsp; pid)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd /var/run<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQUEAK_HTTP_PID=`head squeak.pid` <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; echo &quot;You asked for PID: here:&quot;<br>&nbsp;&nbsp;&nbsp; echo $SQUEAK_HTTP_PID&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ;;<br>&nbsp;&nbsp;&nbsp; *)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;Usage: $0 {start|stop|pid}&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;<br>esac<br><br><br>##########################################################################<br>
<br>I then add the following code in monitrc<br><br><font color="#0000ff" face="Trebuchet MS" size="2"><span>check process squeakvm with pidfile 
/var/run/squeak.pid<br>&nbsp;group server<br>&nbsp;start program = 
&quot;/etc/init.d/seaside start&quot;<br>&nbsp;stop program = &quot;/etc/init.d/seaside 
stop&quot;</span></font>
<div>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;if cpu &gt; 60% for 2 cycles then 
alert<br>&nbsp;if cpu &gt; 80% for 5 cycles then restart<br>&nbsp;if totalmem 
&gt; 200.0 MB for 2 cycles then restart</span></font></div>
<div>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;if loadavg(5min) greater than 10 for 8 cycles 
then restart<br>&nbsp;if 5 restarts within 5 cycles then 
timeout</span></font></div>#####################################################################<br><br>And to my excitement, Monit works for the above set of code.<br>1) I am able to start a seaside image, grep for &#39;squeak&#39; in the ps and assign its PID to a variable and then echo that into /var/run/squeak.pid&nbsp;&nbsp; (here squeak.pid is created or overwritten)<br>
<br>2) When I stop the image, the PID is read from /var/run/squeak.pid and the process is killed, then the file squeak.pid is deleted<br><br>The setup works well. I did the following to test<br><br>$ pkill squeakvm&nbsp; <br>or<br>
$ sudo /etc/init.d/seaside stop<br><br>In both cases, after daemon checking time of 60 seconds, Seaside image was started automatically.<br><br>So far so good, now my only concern in this regard is how to run Multiple seaside/squeak images ?<br>
<br>AFAIK, the default process name for all the squeak instances running are &#39;squeakvm&#39; , how to change this to suit image name or the best thing would be to have seaside_9091&nbsp; (port number.. the way mongrel_8010 is named)<br>
<br>If we get unique process name, then using Monit would become easier.<br><br>Thanks &amp; Regards,<br>Rajeev<br><br><div class="gmail_quote">On Feb 7, 2008 6:46 PM, Sebastian Sastre &lt;<a href="mailto:ssastre@seaswork.com">ssastre@seaswork.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>Well done,</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; if you read the monit documentation 
you will figure out quickly how to use it. And yes you have to set a name for 
each process/image which monit only can discern by looking its pid file. That&#39;s 
why I&#39;ve made those squeak production images to make a pid file with the name of 
the service (only if in unix like OS) and delete it when shutdown. And the 
script that is named with the name of the service.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; I&#39;m also using two scripts one is 
SERVICENAME and the other is SERVICENAMEg. The second is to open the image with 
full display. This can be done in the same script by a different command like 
startHeadfull instead of start and that comand uses the headfull invocation of 
squeak.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; So the scripts to start and stop 
looks pretty much as those but I modify them to allow me to pass as argument a 
configuration file (just a .st file defining a dictionary of options). I think 
they will work for any linux. I needed to make a directory under /var/run to 
store only pids of seaside images to make things more 
simple.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; cheers,</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
<div align="left"><span>
<p style="margin: 0cm 0cm 0pt;" align="left"><span style="font-size: 10pt;">Sebastian 
Sastre</span></p></span></div>
<div>&nbsp;</div><br>
<blockquote style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
  <div dir="ltr" align="left" lang="es">
  <hr>
  <font face="Tahoma" size="2"><div class="Ih2E3d"><b>De:</b> <a href="mailto:seaside-bounces@lists.squeakfoundation.org" target="_blank">seaside-bounces@lists.squeakfoundation.org</a> 
  [mailto:<a href="mailto:seaside-bounces@lists.squeakfoundation.org" target="_blank">seaside-bounces@lists.squeakfoundation.org</a>] <b>En nombre de </b>Rajeev 
  Lochan<br></div><b>Enviado el:</b> Jueves, 07 de Febrero de 2008 
  10:34<br><b>Para:</b> Seaside - general discussion<br><b>Asunto:</b> Re: 
  [Seaside] Monit on Ubuntu / Debian to monitor Seaside 
  images<br></font><br></div><div><div></div><div class="Wj3C7c">
  <div></div>Hi Sebastian,<br>I am figuring out a bit of what you sent me in 
  your reply. OJ7WRE is the name of your Seaside service. I am now searching for 
  init script for Squeak image. Till now, this is the nearest things I have 
  got<br><br><a href="http://wiki.squeak.org/swiki/124" target="_blank">http://wiki.squeak.org/swiki/124</a>&nbsp;&nbsp;&nbsp;&nbsp; 
  for RedHat Distro<br><a href="http://wiki.squeak.org/swiki/123" target="_blank">http://wiki.squeak.org/swiki/123</a>&nbsp;&nbsp;&nbsp;&nbsp; 
  for Solaris<br><br>Which one to go for ?, Is there any other thing much more 
  specific to Debian / Ubuntu . <br><br>Thanks for your help,<br>Rajeev<br><br>
  <div class="gmail_quote">On Feb 7, 2008 2:28 AM, Sebastian Sastre &lt;<a href="mailto:ssastre@seaswork.com" target="_blank">ssastre@seaswork.com</a>&gt; wrote:<br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>Hi Rajeev,</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; Monit its simple and yet 
    powerful.</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; This is how the monitrc file looks like to 
    monitor a squeak image:</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>###############################################################################<br>## 
    Monitoring DEVELOPMENT Service 
    OJ7WRE<br>###############################################################################</span></font></div>
    <div>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;check process OJ7WRE with pidfile 
    /var/run/services/OJ7WRE.pid<br>&nbsp;group server<br>&nbsp;start program = 
    &quot;/etc/init.d/OJ7WRE start&quot;<br>&nbsp;stop program = &quot;/etc/init.d/OJ7WRE 
    stop&quot;</span></font></div>
    <div>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;if cpu &gt; 60% for 2 cycles then alert<br>&nbsp;if cpu 
    &gt; 80% for 5 cycles then restart<br>&nbsp;if totalmem &gt; 200.0 MB for 2 
    cycles then restart</span></font></div>
    <div>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;if loadavg(5min) greater than 10 for 8 cycles then 
    restart<br>&nbsp;if 5 restarts within 5 cycles then 
    timeout</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>###############################################################################</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;the start and stop script is doing more 
    or less what you are doing manually. I send a kill -15 to close image 
    gently. Also I needed to make the pid file when the image starts and remove 
    before image quits. I have an object in the image dedicated to startup and 
    shutdown production stuff inside the image.</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; For a &quot;more monitored&quot; services you can make 
    monit to send you an email to your cell phone if it reach some point (like a 
    service restart or fail to start or CPU 100% for more than 5 min&nbsp;or 
    apache is down or whatever).</span></font></div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span></span></font>&nbsp;</div>
    <div dir="ltr" align="left"><font color="#0000ff" face="Trebuchet MS" size="2"><span>&nbsp;&nbsp;&nbsp; cheers,</span></font></div>
    <div><font color="#0000ff" face="Trebuchet MS" size="2"></font>&nbsp;</div>
    <div align="left"><span>
    <p style="margin: 0cm 0cm 0pt;" align="left"><span style="font-size: 10pt;">Sebastian Sastre</span></p>
    <p style="margin: 0cm 0cm 0pt;"></p>
    <p style="margin: 0cm 0cm 0pt; text-align: justify;"><span style="font-size: 7.5pt; font-family: Verdana;" lang="ES-AR"></span><span lang="ES-AR"><font face="Verdana"></font></span></p></span></div><br>
    <blockquote style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
      <div dir="ltr" align="left" lang="es">
      <hr>
      <font face="Tahoma" size="2"><b>De:</b> <a href="mailto:seaside-bounces@lists.squeakfoundation.org" target="_blank">seaside-bounces@lists.squeakfoundation.org</a> [mailto:<a href="mailto:seaside-bounces@lists.squeakfoundation.org" target="_blank">seaside-bounces@lists.squeakfoundation.org</a>] <b>En nombre 
      de </b>Rajeev Lochan<br><b>Enviado el:</b> Miércoles, 06 de Febrero de 
      2008 17:36<br><b>Para:</b> Seaside - general discussion<br><b>Asunto:</b> 
      [Seaside] Monit on Ubuntu / Debian to monitor Seaside 
      images<br></font><br></div>
      <div>
      <div></div>
      <div>
      <div></div>Hi,<br>I have been working towards setting up a dedicated 
      server (Ubuntu) to host my Seaside app as per Ramon&#39;s Blog <a href="http://onsmalltalk.com/programming/smalltalk/scaling-seaside-redux-enter-the-penguin/" target="_blank">http://onsmalltalk.com/programming/smalltalk/scaling-seaside-redux-enter-the-penguin/</a><br>
<br>Till 
      now, I have been successful in having Apache serve static content and Load 
      balance between 3 images of my Seaside App. Sticky sessions are working 
      and everything is going well so far. But I had a problem when installing 
      Daemontools (which Ramon has written in his blog and also Lukas has 
      written in Mailing lists), the recent versions of Ubuntu, dont support 
      Daemontools out of the box. <br><br>In one of the comments to Ramon&#39;s 
      post, I could learn that some of the seasiders have used Monit to do much 
      more than want Daemontools does. Could you please guide me how to go 
      about.<br><br>I came across a blog on Rails using Monit&nbsp; <a href="http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/" target="_blank">http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/</a><br>
In 
      that, what is the equivalent code to Seaside of the following code 
      ?<br><br><pre><font size="4">start program = <span style="color: rgb(153, 102, 0);">&quot;/usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -p 8010 -a <a href="http://127.0.0.1" target="_blank">127.0.0.1</a> -P /home/user/current/log/mongrel.8010.pid -c /home/user/rails/current&quot;</span><br>


    stop program  = <span style="color: rgb(153, 102, 0);">&quot;/usr/local/bin/ruby /usr/local/bin/mongrel_rails stop -P /home/user/current/log/mongrel.8010.pid&quot;</span></font></pre>Till 
      now, I have been starting the images manually by <br>/seaside$ 
      squeakvm&nbsp; -nodisplay seasidedemo &quot;&quot; port 9090 &amp;<br><br>and to 
      kill it, i use $ pkill squeakvm&nbsp;&nbsp;&nbsp; or $ kill [PID of 
      SqueakVM]<br><br>I suppose, we will also have to change the following 
      code<br><pre><font size="4"><span style="font-weight: bold; color: rgb(153, 102, 204);">if</span> totalmem is greater than <span style="color: rgb(0, 102, 102);">60.0</span> MB <span style="font-weight: bold; color: rgb(153, 102, 204);">for</span> <span style="color: rgb(0, 102, 102);">5</span> cycles <span style="font-weight: bold; color: rgb(153, 102, 204);">then</span> restart<br>


<br></font></pre>When an image is running on my server (Pentium Dual Core 
      2.8 GHz with 1 GB RAM), it shows almost 3-4% CPU and 3-4% RAM , should we 
      shift the memory cap from 60 MB to 100 MB / image ?<br><br><br>Is there 
      any other options we have ? <br><br>Thanks for the 
      help,<br>&nbsp;<br>Rajeev <br><br>Co-founder, AR-CAD.com<br><br><a href="http://www.ar-cad.com" target="_blank">http://www.ar-cad.com</a><br>+91 9243468076 
      (Bangalore)<br>080 65355873 
    </div></div></blockquote></div><br>_______________________________________________<br>seaside 
    mailing list<br><a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br><a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Rajeev Lochan<br><br>Co-founder, AR-CAD.com<br><br><a href="http://www.ar-cad.com" target="_blank">http://www.ar-cad.com</a><br>+91 9243468076 
  (Bangalore)<br>080 65355873 </div></div></blockquote></div>
<br>_______________________________________________<br>seaside mailing list<br><a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br><a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Rajeev Lochan<br><br>Co-founder, AR-CAD.com<br><br><a href="http://www.ar-cad.com">http://www.ar-cad.com</a><br>+91 9243468076 (Bangalore)<br>080 65355873