Access Keys:
Skip to content (Access Key - 0)

Configuring a Grid Container to be Auto-Start and be Managed as a Linux Service.

This page describes how to set up a grid service running under Linux to automatically start when its host boot normally. This page also describes how to allow the grid service to be stopped, started or restarted like any other Linux service.

For the purposes of this page, we will assume:

  • There is a service named xyz. When using the examples that appear on the page be sure to substitute your actual service name for xyz.
  • The xyz service is run in tomcat.
  • xyz runs with the user ID gridAdmin.
  • A login script for gridAdmin such as ~/.bashrc sets the environment variables CATALINA_HOME and GLOBUS_LOCATION to the correct value.
  • /etc/profile or ~/.bashrc sets the environment variable JAVA_HOME to the correct value.
  • You are logged in as gridAdmin to do this configuration.
  • The home directory for gridAdmin is /home/gridAdmin
  • You know the host's root password.
  • ntp.example.net is an is an ntp time server.

Begin by creating these three scripts in /home/gridAdmin/bin (substituting the actual service name for xyz):

  • xyz_start
    #!/bin/sh
    $CATALINA_HOME/bin/startup.sh
  • xyz_stop
    #!/bin/sh
    $CATALINA_HOME/bin/shutdown.sh
  • xyz_restart
    #!/bin/sh
    
    $CATALINA_HOME/bin/shutdown.sh
    sleep 2
    $CATALINA_HOME/bin/startup.sh

Make the three files executable with the following command (substituting the actual service name for xyz):

 chmod +x ~/bin/xyz_start ~/bin/xyz_stop ~/bin/xyz_restart 

Test-run these files to make sure that they work.

The remainder of the configuration must be done while logged in or su'ed as root.

Create a script named /etc/init.d/xyz like this:

#!/bin/sh
case "$1" in
  start)
    /usr/sbin/ntpdate ntp.example.net
    su --login --command=/home/gridAdmin/bin/xyz_start gridAdmin
    ;;

  stop)
    su --login --command=/home/gridAdmin/bin/xyz_stop gridAdmin
    ;;

  restart)
    /usr/sbin/ntpdate ntp.example.net
    su --login --command=/home/gridAdmin/bin/xyz_restart gridAdmin
    ;;

  *)
    echo "Usage $0 start|stop|restart"
    exit 1;;
esac

exit $?

Make the script executable

chmod 755 /etc/init.d/xyz

Test the script to make sure that it works.

The grid service can now be run as a Linux service.

To arrange for the service to be started up after a normal boot (run-level 5) of the host, issue this command:

ln -s /etc/init.d/xyz /etc/rc5.d/S99xyz
Last edited by
Sarah Honacki (448 days ago)
Adaptavist Theme Builder Powered by Atlassian Confluence