<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> <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 it is really "well conceived" meaning you can easily change several things if you use the "defaults" file. And this makes it quite dificult to replicate using Upstart.<BR> <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 a "good" Kamailio start script. So my questions are:<BR> <BR>- Should we keep the user, group, shared memory, package memory, etc. an adjustment to the start script 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> <BR>Very key: is this the right forum to put these questions or there is a more appropriated forum to do so?<BR> <BR>Cheers,<BR> <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>
<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 the upstart script 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>
<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>
<br>
# First save you original init script if you have one<br>
mv /etc/init.d/kamailio ~<br>
<br>
# Create symlink to upstart .conf file<br>
ln -s /etc/init/kamailio.conf /etc/init.d/kamailio<br>
<br>
Then create a /etc/init/kamailio.conf (notice it is /etc/init/ <strong>not</strong>
/etc/init.d/) with the following content:<br>
<br>
# Kamailio Service<br>
<br>
description "Kamailio server"<br>
author "Moacir Ferreira"<br>
<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>
<br>
start on runlevel [2345]<br>
stop on starting rc RUNLEVEL=[016]<br>
<br>
# This is required to start Kamailio<br>
# after MySQL<br>
start on started mysql<br>
<br>
# This is required when the daemon<br>
# forks 2 times<br>
expect daemon<br>
<br>
# Include this to see the nice<br>
# kamailo init messages at the console<br>
console output<br>
<br>
pre-start script<br>
<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>
echo "$NAME ERROR: Kamilio not set to fork. Review your
config or start it in debug mode.";<br>
exit 1;<br>
fi<br>
<br>
# Check if kamailio configuration is valid before starting the
server.<br>
out=$($DAEMON -c 2>&1 > /dev/null)<br>
retcode=$?<br>
set -e<br>
if [ "$retcode" != '0' ]; then<br>
echo "$NAME ERROR: Config file invalid."<br>
exit 1;<br>
fi<br>
<br>
end script<br>
<br>
exec $DAEMON -f $CFGFILE -u $USER -g $GROUP<br>
<br>
# This is the end of the script<br>
<br>
Good luck and Cheers!<br>
<br>
Moacir<br>
<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 get the
Kamailio community to 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>
<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"> <br>
Moacir<br>
<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<run-level>.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:
> My kamailio start script has the following BEGIN INIT INFO:
>
> #
> ### BEGIN INIT INFO
> # Provides: kamailio
> # Required-Start: $syslog $network $local_fs $time mysql
> # Required-Stop: $syslog $network $local_fs mysql
> # Default-Start: 2 3 4 5
> # Default-Stop: 0 1 6
> # Should-Start: postgresql mysql radius
> # Should-Stop: postgresql mysql radius
> # Short-Description: Start the Kamailio SIP proxy server
> # Description: Start the Kamailio SIP proxy server
> ### END INIT INFO
>
> However, when I boot my server Kamailio will start before mysql. So,
> after boot I can start Kamalio but at boot time it will fail.
>
> Any hints how to fix it? I am running Ubuntu server 12.04 LTS - 64 bits.
> All the code has been compiled at the server.
>
> Cheers!
>
> Moacir
>
>
> _______________________________________________
> 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 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>
</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>