[SR-Users] Returning problem

Moacir Ferreira moacirferreira at hotmail.com
Mon Nov 19 12:19:31 CET 2012


Hi, Please notice that the original problem is Kamailio starting before MySQL on Ubuntu and that the reason is because Kamailio is using the standard init.d script and MySQL is using upstart. Now, installing MySQL server on Ubuntu is a quite simple command: apt-get install mysql-server (and this is what I do to get it installed). We can conclude that the MySQL  package for Ubuntu, from the official repositories, is already using Upstart. So, to solve the starting problem you must either change MySQL back to init.d or Kamailio to Upstart. I don't believe that moving MySQL back to init.d would be a good idea as anytime you do an upgrade from the repositories you could end up having problems with the start script. Also, you would have to maintain you own start script. Of course it is up to anyone decide the best way. But the key point is: installing Kamailio+MySQL on Ubuntu will fail to start Kamailio at the boot time if Kamailio does not include the proper Upstart configuration.
Cheers! MoacirDate: Mon, 19 Nov 2012 10:07:18 +0100
From: miconda at gmail.com
To: moacirferreira at hotmail.com
CC: sr-users at lists.sip-router.org
Subject: Re: [SR-Users] Returning problem


  
    
  
  
    Hello,

    

    thanks for the sample upstart script. Perhaps it would be good to be
    added in the tracker not to get lost.

    

    As said, I am not familiar with upstart, maybe someone else can
    contribute other improvements for the moment.

    

    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.

    

    Cheers,

    Daniel

    

    On 11/15/12 9:12 PM, Moacir Ferreira
      wrote:

    
    
      
      
        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.

         

        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.

         

        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:

         

        # First save you original init script if you have one

        mv /etc/init.d/kamailio ~

         

        # Create symlink to upstart .conf file

        ln -s /etc/init/kamailio.conf /etc/init.d/kamailio

         

        Then create a /etc/init/kamailio.conf (notice it is /etc/init/ not
        /etc/init.d/) with the following content:

         

        # Kamailio Service

         

        description   "Kamailio server"

        author         "Moacir Ferreira"

         

        # Change anything here

        # to match your environment

        env NAME=kamailio

        env DAEMON=/sbin/kamailio

        env CFGFILE=/etc/kamailio/kamailio.cfg

        env USER=kamailio

        env GROUP=kamailio

         

        start on runlevel [2345]

        stop on starting rc RUNLEVEL=[016]

         

        # This is required to start Kamailio

        # after MySQL

        start on started mysql

         

        # This is required when the daemon

        # forks 2 times

        expect daemon

         

        # Include this to see the nice

        # kamailo init messages at the console

        console output

         

        pre-start script

         

        # Do not start kamailio if fork=no is set in the config file

        if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*"
        $CFGFILE; then

           echo "$NAME ERROR: Kamilio not set to fork. Review your
        config or start it in debug mode.";

           exit 1;

        fi

         

        # Check if kamailio configuration is valid before starting the
        server.

        out=$($DAEMON -c 2>&1 > /dev/null)

        retcode=$?

        set -e

        if [ "$retcode" != '0' ]; then

           echo "$NAME ERROR: Config file invalid."

           exit 1;

        fi

         

        end script

         

        exec $DAEMON -f $CFGFILE -u $USER -g $GROUP

         

        # This is the end of the script

         

        Good luck and Cheers!

         

        Moacir

         

        
          Date: Wed, 14 Nov 2012 06:36:40 -0500

          From: miconda at gmail.com

          To: sr-users at lists.sip-router.org

          CC: moacirferreira at hotmail.com

          Subject: Re: [SR-Users] Returning problem

          

          Hello,

          

          On 11/13/12 6:15 PM, Moacir
            Ferreira wrote:

          
          
            
             I wish it were that simple... I have done
              some "reading" and found that Ubuntu has changed to
              upstart http://upstart.ubuntu.com/cookbook/.
              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.

               

              Any help?

            
          
          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.

          

          Cheers,

          Daniel

          
             

              Moacir

               

              From: 4lists at gmail.com

              To: sr-users at lists.sip-router.org

              Date: Mon, 12 Nov 2012 14:42:31 -0200

              Subject: Re: [SR-Users] Returning problem

              

              

              
                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
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
 
 

              
            
            

            
            

            _______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users at lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

          
          

          -- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
        
      
    
    

    -- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20121119/12aa10b0/attachment.htm>


More information about the sr-users mailing list