0

I created a system service which can be start/stop/restart by running the command service. But when I try to do it by systemctl I always got below error. I don't know what wrong with my script file. Why it can be managed by service not systemctl?

# systemctl restart cooltoo_storage
Job for cooltoo_storage.service failed because the control process exited with error code. See "systemctl status cooltoo_storage.service" and "journalctl -xe" for details.

Below is the output of "systemctl status cooltoo_storage.service"

# systemctl status cooltoo_storage.service

● cooltoo_storage.service - LSB: cooltoo storage provider Loaded: loaded (/etc/rc.d/init.d/cooltoo_storage) Active: failed (Result: exit-code) since Tue 2016-05-03 17:17:12 CST; 1min 29s ago Docs: man:systemd-sysv-generator(8) Process: 32268 ExecStart=/etc/rc.d/init.d/cooltoo_storage start (code=exited, status=203/EXEC)

May 03 17:17:12 Cool-Too systemd[1]: Starting LSB: cooltoo storage provider...
May 03 17:17:12 Cool-Too systemd[1]: cooltoo_storage.service: control  process exited, code=exited status=203
May 03 17:17:12 Cool-Too systemd[1]: Failed to start LSB: cooltoo storage provider.
May 03 17:17:12 Cool-Too systemd[1]: Unit cooltoo_storage.service entered failed state.
May 03 17:17:12 Cool-Too systemd[1]: cooltoo_storage.service failed.

Below is my script file /etc/init.d/cooltoo_storage,

### BEGIN INIT INFO
# Provides:          cooltoo storage provider
# Required-Start:    $local_fs $remote_fs $network $time $named
# Should-Start: $time sendmail
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: cooltoo storage provider
# Description:       cooltoo storage provider
# chkconfig: 2345 90 90
### END INIT INFO

start() {
  nginx -c /data/nginx/nginx.config
}

stop() {
        nginx -c /data/nginx/nginx.config -s stop
}

restart() {
        nginx -c /data/nginx/nginx.config -s reload
}

status() {
        echo ''
}



action="$@"
if [[ "$MODE" == "auto" && -n "$init_script" ]] || [[ "$MODE" == "service" ]]; then
  action="$1"
  shift
fi


case "$action" in
start)
  start ; exit $?;;
stop)
  stop ; exit $?;;
restart)
  restart ; exit $?;;
status)
  status ; exit $?;;
*)
  echo "Usage: $0 {start|stop|restart|force-reload|status|run}"; exit 1;
esac
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

0 Answers0