当我开始自己的服务时出现错误" adtech.service的工作失败。"

时间:2015-12-04 04:12:48

标签: linux bash shell sh

我写了一个服务来包装作为服务运行的jar文件..这是服务文件。

#!/bin/sh-
SERVICE_NAME=adtech-service
PATH_TO_JAR=/opt/ADTECH/dist/ADTECH.jar
PID_PATH_NAME=/tmp/adtech-service-pid
case $1 in
    start)
        echo "Starting $SERVICE_NAME ..."
        if [ ! -f $PID_PATH_NAME ]; then
            nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
                        echo $! > $PID_PATH_NAME
            echo "$SERVICE_NAME started ..."
        else
            echo "$SERVICE_NAME is already running ..."
        fi
    ;;
    stop)
        if [ -f $PID_PATH_NAME ]; then
            PID=$(cat $PID_PATH_NAME);
            echo "$SERVICE_NAME stoping ..."
            kill $PID;
            echo "$SERVICE_NAME stopped ..."
            rm $PID_PATH_NAME
        else
            echo "$SERVICE_NAME is not running ..."
        fi
    ;;
    restart)
        if [ -f $PID_PATH_NAME ]; then
            PID=$(cat $PID_PATH_NAME);
            echo "$SERVICE_NAME stopping ...";
            kill $PID;
            echo "$SERVICE_NAME stopped ...";
            rm $PID_PATH_NAME
            echo "$SERVICE_NAME starting ..."
            nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
                        echo $! > $PID_PATH_NAME
            echo "$SERVICE_NAME started ..."
        else
            echo "$SERVICE_NAME is not running ..."
        fi
    ;;
esac

在我尝试通过以下代码开始执行服务之后。

sudo service adtech start

但是它给出了以下错误

Job for adtech.service failed. See "systemctl status adtech.service" and "journalctl -xe" for details.
root@eyepax-staging:/# systemctl status adtech.service
● adtech.service - (null)
      Loaded: loaded (/etc/init.d/adtech)
      Active: failed (Result: exit-code) since Fri 2015-12-04 03:52:19 UTC; 12s ago
      Docs: man:systemd-sysv-generator(8)
      Process: 10913 ExecStart=/etc/init.d/adtech start (code=exited, status=203/EXEC)

Dec 04 03:52:19 eyepax-staging systemd[1]: Starting (null)...
Dec 04 03:52:19 eyepax-staging systemd[1]: adtech.service: control process exited, code=exited status=203
Dec 04 03:52:19 eyepax-staging systemd[1]: Failed to start (null).
Dec 04 03:52:19 eyepax-staging systemd[1]: Unit adtech.service entered failed state.
Dec 04 03:52:19 eyepax-staging systemd[1]: adtech.service failed.

任何人都可以告诉我我的代码有什么问题吗?

0 个答案:

没有答案