如何使用systemctl重新启动服务

时间:2016-05-03 09:22:06

标签: linux systemctl

我创建了一个系统服务,可以通过运行命令服务来启动/停止/重启。但是当我尝试通过systemctl执行此操作时,我总是遇到错误。我不知道我的脚本文件有什么问题。为什么它可以通过服务而不是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.

以下是“systemctl status cooltoo_storage.service”

的输出
# systemctl status cooltoo_storage.service

●cooltoo_storage.service - LSB:cooltoo存储提供商    已加载:已加载(/etc/rc.d/init.d/cooltoo_storage)    活动:失败(结果:退出代码)自Tue 2016-05-03 17:17:12 CST; 1分29秒前      文档:man:systemd-sysv-generator(8)   处理: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.

以下是我的脚本文件/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

0 个答案:

没有答案