Search This Blog

Monday, August 11, 2008

Creating service starting script

One of our customer ask what to do to start IsoStar server during system start. Our customer was using Centos (RedHat derivative) so I suggested to use the command line tool called chkconfig [1, 2]. TO use this tool you need a special script starting Isostar Apache server. The sample of such script can be found here [3]. Here is the example instruction. Let me assume that isostar is going to /opt directory.
  1. Copy the script from link [3] to your HDD and call it isostar_server
  2. Change line:
    /path/to/command/to/start/new-service
    to:
    /opt/csd/isostar/APACHE/bin/ccdc_apache start
    and line:
    /path/to/command/to/stop/new-service
    to:
    /opt/csd/isostar/APACHE/bin/ccdc_apache stop
  3. Remove following lines (from both start and stop subsection):
          #Or to run it as some other user:
    /bin/su - username -c /path/to/command/to/start/new-service
    echo "."
  4. Change 'new-service' in 'echo -n' lines to 'isostar_server'.
  5. Now as a root copy isostar_server file into /etc/init.d/
  6. Again as a root invoke chkconfig and add isostar_server: /sbin/chkconfig --add isostar_server
There are very similar tool for Debian (Ubuntu etc.) called update-rc.d [4, 5]. You should be able to use following command with the same (very similar script): update-rc.d isostar_server start 90 2 3 4 5 . stop 10 0 1 6.
Links
[1] http://linux.die.net/man/8/chkconfig
[2] http://spiralbound.net/2006/11/15/controlling-services-with-chkconfig
[3] http://spiralbound.net/2007/07/23/example-linux-init-script
[4] http://wiki.linuxquestions.org/wiki/Update-rc.d
[5] http://www.annodex.net/cgi-bin/man/man2html?update-rc.d+8

No comments: