Start Up and Shut Down Scripts
Scripts provide a consistent method to start up and shut down services on Linux.
This article applies to: Managed Servers
Use this procedure as a consistent method of starting services on Unix. A side benefit of this procedure is that it keeps user-space applications out of the system startup/shutdown process so they do not hinder a system during boot or shutdown.
The system directory tree "/usr/app/" exists to provide this startup/shutdown capability. Each service will have its own subdirectory containing the scripts required to start, stop and perform daily cleanup tasks. Services are registered in the file "/usr/app/services.node" so the system knows which ones to start/stop.
Basic "cleanup" functionality is provided if you create a script "rc.cleanup"; this script will be run daily at 4:15am. Typical uses include cleaning up log files and/or temporary files.
Do not install other application-specific files in "/usr/app/." That directory should contain only the three scripts for startup (rc.local), shutdown (rc.shutdown) and the optional cleanup script (rc.cleanup).
To use start up and shut down scripts
Create subdirectory of /usr/app for your service:
sudo mkdir /usr/app/
Create "etc" subdirectory to hold your scripts:
sudo mkdir /usr/app/SERVICENAME/etc
Create startup script "rc.local":
sudo vi /usr/app/SERVICENAME/etc/rc.local
Create shutdown script "rc.shutdown":
sudo vi /usr/app/SERVICENAME/etc/rc.shutdown
OPTIONAL: Create daily cleanup script "rc.cleanup":
sudo vi /usr/app/SERVICENAME/etc/rc.cleanup
- Test your scripts manually to make sure they actually start, shut down, and clean up after your application.
Add the name of your directory to "services.node":
sudo vi /usr/app/services.node
The directory name is relative to "/usr/app/" and should not contain slashes.
Continuing with the example, add
SERVICENAMEto the file on a line by itself.