Guest User

Untitled

a guest
Sep 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # chkconfig: 35 95 05
  4. # description: Hello world application.
  5.  
  6. # Run at startup: sudo chkconfig hello-world on
  7.  
  8. # Load functions from library
  9. . /etc/init.d/functions
  10.  
  11. # Name of the application
  12. app="hello-world"
  13.  
  14. # Start the service
  15. start() {
  16. # If the application is currently running
  17. if [ -f /var/lock/subsys/$app ] && ps -p `cat /var/lock/subsys/$app` > /dev/null 2>&1; then
  18. status $app
  19. exit 1
  20. else
  21. echo -n $"Starting $app:"
  22. cd /home/ec2-user/workspace/bin/$app
  23. ./$app > log.out 2> log.err < /dev/null &
  24. # Store PID in lock file
  25. echo $! > /var/lock/subsys/$app
  26. success
  27. echo
  28. fi
  29. }
  30.  
  31. # Restart the service
  32. stop() {
  33. echo -n "Stopping $app: "
  34. killproc $app
  35. rm -f /var/lock/subsys/$app
  36. echo
  37. }
  38.  
  39. # Main logic
  40. case "$1" in
  41. start)
  42. start
  43. ;;
  44. stop)
  45. stop
  46. ;;
  47. status)
  48. status $app
  49. ;;
  50. restart|reload)
  51. stop
  52. start
  53. ;;
  54. *)
  55. echo $"Usage: $0 {start|stop|restart|reload|status}"
  56. exit 1
  57. esac
  58. exit 0
Add Comment
Please, Sign In to add comment