server.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. SERVER="cock_data"
  3. BASE_DIR=/data/www/cockData/deploy
  4. INTERVAL=2
  5. function start() {
  6. if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
  7. echo "$SERVER already running"
  8. exit 1
  9. fi
  10. export RAGDOLL_CONFIG=$BASE_DIR/profiles/test/ragdoll_config.yml
  11. nohup $BASE_DIR/$SERVER >/dev/null 2>&1 &
  12. echo "sleeping..." && sleep $INTERVAL
  13. # check status
  14. if [ "$(pgrep $SERVER -u $UID)" == "" ]; then
  15. echo "$SERVER start failed"
  16. exit 1
  17. else
  18. echo "start success"
  19. fi
  20. }
  21. function status() {
  22. if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
  23. echo $SERVER is running
  24. else
  25. echo $SERVER is not running
  26. fi
  27. }
  28. function stop() {
  29. if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
  30. kill $(pgrep $SERVER -u $UID)
  31. fi
  32. echo "sleeping..." && sleep $INTERVAL
  33. if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
  34. echo "$SERVER stop failed"
  35. exit 1
  36. else
  37. echo "stop success"
  38. fi
  39. }
  40. function version() {
  41. $BASE_DIR/$SERVER $ARGS version
  42. }
  43. case "$1" in
  44. 'start')
  45. start
  46. ;;
  47. 'stop')
  48. stop
  49. ;;
  50. 'status')
  51. status
  52. ;;
  53. 'restart')
  54. stop && start
  55. ;;
  56. 'version')
  57. version
  58. ;;
  59. *)
  60. echo "usage: $0 {start|stop|restart|status|version}"
  61. exit 1
  62. ;;
  63. esac