Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # chkconfig: 35 95 05
- # description: Hello world application.
- # Run at startup: sudo chkconfig hello-world on
- # Load functions from library
- . /etc/init.d/functions
- # Name of the application
- app="hello-world"
- # Start the service
- start() {
- # If the application is currently running
- if [ -f /var/lock/subsys/$app ] && ps -p `cat /var/lock/subsys/$app` > /dev/null 2>&1; then
- status $app
- exit 1
- else
- echo -n $"Starting $app:"
- cd /home/ec2-user/workspace/bin/$app
- ./$app > log.out 2> log.err < /dev/null &
- # Store PID in lock file
- echo $! > /var/lock/subsys/$app
- success
- echo
- fi
- }
- # Restart the service
- stop() {
- echo -n "Stopping $app: "
- killproc $app
- rm -f /var/lock/subsys/$app
- echo
- }
- # Main logic
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status $app
- ;;
- restart|reload)
- stop
- start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|status}"
- exit 1
- esac
- exit 0
Add Comment
Please, Sign In to add comment