12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/bin/bash
- SERVER="cock_data"
- BASE_DIR=/data/www/cockData/deploy
- INTERVAL=2
- function start() {
- if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
- echo "$SERVER already running"
- exit 1
- fi
- export RAGDOLL_CONFIG=$BASE_DIR/profiles/test/ragdoll_config.yml
- nohup $BASE_DIR/$SERVER >/dev/null 2>&1 &
- echo "sleeping..." && sleep $INTERVAL
- # check status
- if [ "$(pgrep $SERVER -u $UID)" == "" ]; then
- echo "$SERVER start failed"
- exit 1
- else
- echo "start success"
- fi
- }
- function status() {
- if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
- echo $SERVER is running
- else
- echo $SERVER is not running
- fi
- }
- function stop() {
- if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
- kill $(pgrep $SERVER -u $UID)
- fi
- echo "sleeping..." && sleep $INTERVAL
- if [ "$(pgrep $SERVER -u $UID)" != "" ]; then
- echo "$SERVER stop failed"
- exit 1
- else
- echo "stop success"
- fi
- }
- function version() {
- $BASE_DIR/$SERVER $ARGS version
- }
- case "$1" in
- 'start')
- start
- ;;
- 'stop')
- stop
- ;;
- 'status')
- status
- ;;
- 'restart')
- stop && start
- ;;
- 'version')
- version
- ;;
- *)
- echo "usage: $0 {start|stop|restart|status|version}"
- exit 1
- ;;
- esac
|