<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hello,<BR>&nbsp;<BR>Reading the Upstart "very long cookbook" (<a href="http://upstart.ubuntu.com/cookbook/">http://upstart.ubuntu.com/cookbook/</a>) a lot of things changes when using it. Trying to adapt the current init script I found that&nbsp;it&nbsp;is really "well conceived" meaning you can easily change several&nbsp;things if you use the&nbsp;"defaults" file. And this makes it quite dificult to replicate using Upstart.<BR>&nbsp;<BR>Now, I am not sure about what "features" should I really care when converting the existing init script to a new one. So can anyone help me here? What I need to know is what is, nowadays, what is relevant for&nbsp;a "good"&nbsp;Kamailio start script. So my questions are:<BR>&nbsp;<BR>- Should we keep the user, group, shared memory, package memory, etc. an adjustment to the start script&nbsp;to be configured by the "defaults" file?<BR>- The PID file is quite well controlled by Upstart to allow shutting down the service properly. Any reasonable reason to still define the PID file at Kamailio start?<BR>&nbsp;<BR>Very key: is this the right forum to put these questions or there is a more appropriated forum to do so?<BR>&nbsp;<BR>Cheers,<BR>&nbsp;<BR>Moacir<BR><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">Date: Mon, 19 Nov 2012 10:07:18 +0100<br>From: miconda@gmail.com<br>To: moacirferreira@hotmail.com<br>CC: sr-users@lists.sip-router.org<br>Subject: Re: [SR-Users] Returning problem<br><br>
  
    
  
  
    Hello,<br>
    <br>
    thanks for the sample upstart script. Perhaps it would be good to be
    added in the tracker not to get lost.<br>
    <br>
    As said, I am not familiar with upstart, maybe someone else can
    contribute other improvements for the moment.<br>
    <br>
    Btw, is upstart the default init system for ubuntu 12.04, or is just
    an alternative? Kamailio is packaged on official Debian distro, I
    wonder if the follow the same init system already.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="ecxmoz-cite-prefix">On 11/15/12 9:12 PM, Moacir Ferreira
      wrote:<br>
    </div>
    <blockquote cite="mid:COL125-W23A790EAF45EF9E2A491C3C8520@phx.gbl">
      <style><!--
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}

--></style>
      <div dir="ltr">
        Before using my suggestion below, please consider first that I
        am a "dummy programmer" and then, that I am using Ubuntu server
        12.04 LTS 64 bits. If you are using another distro or version,
        you may need to adapt the upstart script. Also, I am not sure if
        this is the right way of doing it, but it worked for me...
        Finally, I did not convert some of the start-up scripts.<br>
        &nbsp;<br>
        Now, the problem I see is that this addresses "my problem"
        (Kamailio+MySQL on Ubuntu running Upstart). However, it would be
        nice to have a more complete script. I.e.: If you are not
        running MySQL, then you have to change&nbsp;the upstart script&nbsp;to
        match your SQL engine. The old init script had a "Should-Start"
        statement so you could get anything to start before Kamailio
        (postgresql mysql radius, etc.) without being a "must" like in
        upstart. But I could not find the equivalent command for this in
        Upstart docs... So I let here the challenge for the community to
        improve what I could accomplish so far.<br>
        &nbsp;<br>
        The first thing you need to do is to remove (or not install) the
        /etc/init.d/kamailio init script. Then you need to create a
        symlink to the kamailio upstart conf file that should be at
        /ect/init/. To do so:<br>
        &nbsp;<br>
        # First save you original init script if you have one<br>
        mv /etc/init.d/kamailio ~<br>
        &nbsp;<br>
        # Create symlink to upstart .conf file<br>
        ln -s /etc/init/kamailio.conf /etc/init.d/kamailio<br>
        &nbsp;<br>
        Then create a /etc/init/kamailio.conf (notice it is /etc/init/ <strong>not</strong>
        /etc/init.d/) with the following content:<br>
        &nbsp;<br>
        # Kamailio Service<br>
        &nbsp;<br>
        description&nbsp;&nbsp; "Kamailio server"<br>
        author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Moacir Ferreira"<br>
        &nbsp;<br>
        # Change anything here<br>
        # to match your environment<br>
        env NAME=kamailio<br>
        env DAEMON=/sbin/kamailio<br>
        env CFGFILE=/etc/kamailio/kamailio.cfg<br>
        env USER=kamailio<br>
        env GROUP=kamailio<br>
        &nbsp;<br>
        start on runlevel [2345]<br>
        stop on starting rc RUNLEVEL=[016]<br>
        &nbsp;<br>
        # This is required to start Kamailio<br>
        # after MySQL<br>
        start on started mysql<br>
        &nbsp;<br>
        # This is required when the daemon<br>
        # forks 2 times<br>
        expect daemon<br>
        &nbsp;<br>
        # Include this to see the nice<br>
        # kamailo init messages at the console<br>
        console output<br>
        &nbsp;<br>
        pre-start script<br>
        &nbsp;<br>
        # Do not start kamailio if fork=no is set in the config file<br>
        if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*"
        $CFGFILE; then<br>
        &nbsp;&nbsp; echo "$NAME ERROR: Kamilio not set to fork. Review your
        config or start it in debug mode.";<br>
        &nbsp;&nbsp; exit 1;<br>
        fi<br>
        &nbsp;<br>
        # Check if kamailio configuration is valid before starting the
        server.<br>
        out=$($DAEMON -c 2&gt;&amp;1 &gt; /dev/null)<br>
        retcode=$?<br>
        set -e<br>
        if [ "$retcode" != '0' ]; then<br>
        &nbsp;&nbsp; echo "$NAME ERROR: Config file invalid."<br>
        &nbsp;&nbsp; exit 1;<br>
        fi<br>
        &nbsp;<br>
        end script<br>
        &nbsp;<br>
        exec $DAEMON -f $CFGFILE -u $USER -g $GROUP<br>
        &nbsp;<br>
        # This is the end of the script<br>
        &nbsp;<br>
        Good luck and Cheers!<br>
        &nbsp;<br>
        Moacir<br>
        &nbsp;<br>
        <div>
          <hr id="ecxstopSpelling">Date: Wed, 14 Nov 2012 06:36:40 -0500<br>
          From: <a class="ecxmoz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a><br>
          To: <a class="ecxmoz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
          CC: <a class="ecxmoz-txt-link-abbreviated" href="mailto:moacirferreira@hotmail.com">moacirferreira@hotmail.com</a><br>
          Subject: Re: [SR-Users] Returning problem<br>
          <br>
          Hello,<br>
          <br>
          <div class="ecxmoz-cite-prefix">On 11/13/12 6:15 PM, Moacir
            Ferreira wrote:<br>
          </div>
          <blockquote cite="mid:COL125-W3986EA29065F0966C8AE6C86C0@phx.gbl">
            <style><!--
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}

--></style>
            <div dir="ltr"> I wish it were that simple... I have done
              some "reading" and found that Ubuntu has changed to
              upstart <a href="http://upstart.ubuntu.com/cookbook/" target="_blank">http://upstart.ubuntu.com/cookbook/</a>.
              However, I could not find how I can start a non "upstart"
              style init script like Kamailio has before the upstart
              styled ones... I guess that I have to either to&nbsp;get the
              Kamailio community to&nbsp;create an upstart script or find
              some help from the Ubuntu community how to overcome the
              problem. Anyway, I think the Kamailio team should address
              it as it will become a problem for everyone using Kamailio
              on Ubuntu.<br>
              &nbsp;<br>
              Any help?<br>
            </div>
          </blockquote>
          the link to the upstart documentation you gave has quite big
          content, couldn't you find a migration guide from classic
          init.d to upstart somewhere out there on the web? Might be
          easier to do it then.<br>
          <br>
          Cheers,<br>
          Daniel<br>
          <blockquote cite="mid:COL125-W3986EA29065F0966C8AE6C86C0@phx.gbl">
            <div dir="ltr">&nbsp;<br>
              Moacir<br>
              &nbsp;<br>
              From: <a class="ecxmoz-txt-link-abbreviated" href="mailto:4lists@gmail.com">4lists@gmail.com</a><br>
              To: <a class="ecxmoz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
              Date: Mon, 12 Nov 2012 14:42:31 -0200<br>
              Subject: Re: [SR-Users] Returning problem<br>
              <br>
              <br>
              <div>
                <pre>This is more a system initialization problem, so, take a look in your 
/etc/rc&lt;run-level&gt;.d directory (or the correspondent one), specially in 
the S* files and find out the start sequence. There You'll find the answer.
 
Edson.
 
Em 09/11/2012 17:03, Moacir Ferreira escreveu:
&gt; My kamailio start script has the following BEGIN INIT INFO:
&gt;
&gt; #
&gt; ### BEGIN INIT INFO
&gt; # Provides:          kamailio
&gt; # Required-Start:    $syslog $network $local_fs $time mysql
&gt; # Required-Stop:     $syslog $network $local_fs mysql
&gt; # Default-Start:     2 3 4 5
&gt; # Default-Stop:      0 1 6
&gt; # Should-Start:      postgresql mysql radius
&gt; # Should-Stop:       postgresql mysql radius
&gt; # Short-Description: Start the Kamailio SIP proxy server
&gt; # Description:       Start the Kamailio SIP proxy server
&gt; ### END INIT INFO
&gt;
&gt; However, when I boot my server Kamailio will start before mysql. So,
&gt; after boot I can start Kamalio but at boot time it will fail.
&gt;
&gt; Any hints how to fix it? I am running Ubuntu server 12.04 LTS - 64 bits.
&gt; All the code has been compiled at the server.
&gt;
&gt; Cheers!
&gt;
&gt; Moacir
&gt;
&gt;
&gt; _______________________________________________
&gt; SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
&gt; <a class="ecxmoz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
&gt; <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
&gt;
 
 
</pre>
              </div>
            </div>
            <br>
            <fieldset class="ecxmimeAttachmentHeader"></fieldset>
            <br>
            <pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="ecxmoz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="ecxmoz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
          </blockquote>
          <br>
          <pre class="ecxmoz-signature">-- 
Daniel-Constantin Mierla - <a class="ecxmoz-txt-link-freetext" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
<a class="ecxmoz-txt-link-freetext" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a class="ecxmoz-txt-link-freetext" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
        </div>
      </div>
    </blockquote>
    <br>
    <pre class="ecxmoz-signature">-- 
Daniel-Constantin Mierla - <a class="ecxmoz-txt-link-freetext" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
<a class="ecxmoz-txt-link-freetext" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a class="ecxmoz-txt-link-freetext" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre></div>                                               </div></body>
</html>