systemd service é desligado por conta própria

1

Eu tenho um problema com este serviço do SystemD:

[unidade] Descrição = Serviços de Cliente RTC After = rds.service Requer = rds.service

[Service]
User=USER
Group=GROUP
PermissionsStartOnly=true
RuntimeDirectory=rtc_client
RuntimeDirectoryMode=0770
WorkingDirectory=/usr/lib/systemd/scripts/
Type=forking
ExecStartPre=/bin/mkdir -p /var/run/rtc_client
ExecStartPre=/bin/chown -R USER:GROUP /var/run/rtc_client
ExecStart=/bin/bash rtc_client.sh start
ExecStop=/bin/bash rtc_client.sh stop
Restart=no
PIDFile=/var/run/rtc_client/rtc_client.pid
TimeoutStartSec=0
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

A máquina arranca todas as manhãs. O serviço executa o ExecStart, mas de repente ele pára, enquanto tenta matar o processo PID:

rtc_client.service - RTC Client Services
   Loaded: loaded (/usr/lib/systemd/system/rtc_client.service; enabled)
   Active: failed (Result: exit-code) since Thu 2016-06-23 06:25:46 CEST; 3h 33min ago
  Process: 2754 **ExecStop**=/bin/bash rtc_client.sh stop (code=exited, status=0/SUCCESS)
  Process: 1819 **ExecStart**=/bin/bash rtc_client.sh start (code=exited, status=0/SUCCESS)
  Process: 1815 ExecStartPre=/bin/chown -R USER:USER /var/run/rtc_client (code=exited, status=0/SUCCESS)
  Process: 1813 ExecStartPre=/bin/mkdir -p /var/run/rtc_client (code=exited, status=0/SUCCESS)
 Main PID: 1949 (code=exited, status=1/FAILURE)
   CGroup: /system.slice/rtc_client.service

Jun 23 06:25:46 zprds60 bash[2754]: Database Connection Information
Jun 23 06:25:46 zprds60 bash[2754]: Database server        = DB2/LINUXZ64 10.5.5
Jun 23 06:25:46 zprds60 bash[2754]: SQL authorization ID   = USER
Jun 23 06:25:46 zprds60 bash[2754]: Local database alias   = DBALIAS
Jun 23 06:25:46 zprds60 bash[2754]: /home/pers5i/.bash_profile: line 97: unalias: vi: not found
Jun 23 06:25:46 zprds60 bash[2754]: USER IS:  root
Jun 23 06:25:46 zprds60 bash[2754]: PID IS:  1949
**Jun 23 06:25:46 zprds60 bash[2754]: rtc_client.sh: line 34: kill: (1949) - No such process**
Jun 23 06:25:46 zprds60 bash[2754]: logout
Jun 23 06:25:46 zprds60 systemd[1]: Unit rtc_client.service entered failed state.

Este é o script que o rtc_client.service lança:

#!/bin/bash

RTCENGINEID=$HOSTNAME'_engine'
RTCUSER='RTCUSER'
RTCPW='RTCPWD'
RTCSERVER='server.example.com'
RTCSERVERPORT='????'
RTCREPOSITORY=https://$RTCSERVER:$RTCSERVERPORT/ccm
WORKDIR='/opt/ibm/buildsystemtoolkit/buildsystem/buildengine/eclipse'
JAVACMD=/opt/ibm/java-s390x-71/jre/bin/java
ARGS="-cp ./plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar org.eclipse.equinox.launcher.Main -application com.ibm.team.build.engine.jazzBuildEngine -repository $RTCREPOSITORY -engineId $RTCENGINEID -userId $RTCUSER -pass $RTCPW"
RTCJAR=org.eclipse.equinox.launcher
PIDFILE='/var/run/rtc_client/rtc_client.pid'
DEBUGLOG='/tmp/rtc_debug.log'

. /home/USER/.bash_profile

start() {

        cd $WORKDIR
        nohup $JAVACMD $ARGS > $DEBUGLOG &
        sleep 5
        pgrep -f $RTCJAR > $PIDFILE
        echo "USER IS: " $(whoami) | tee -a $DEBUGLOG
        echo "PID IS: " $(cat $PIDFILE) | tee -a $DEBUGLOG

}


stop() {

        echo "USER IS: " $(whoami) | tee -a $DEBUGLOG
        echo "PID IS: " $(cat $PIDFILE) | tee -a $DEBUGLOG
        kill $(cat $PIDFILE)
        rm -f $PIDFILE

}

restart() {

        stop
        start

}

reload() {

        restart

}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  reload)
        reload
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?

O mais estranho é que, se eu iniciar o serviço ou reiniciar a máquina durante o dia, o serviço será iniciado e permanecerá ativo ...

Loaded: loaded (/usr/lib/systemd/system/rtc_client.service; enabled)
   Active: active (running) since Thu 2016-06-23 10:21:44 CEST; 4s ago
  Process: 2754 ExecStop=/bin/bash rtc_client.sh stop (code=exited, status=0/SUCCESS)
  Process: 38200 ExecStart=/bin/bash rtc_client.sh start (code=exited, status=0/SUCCESS)
  Process: 38195 ExecStartPre=/bin/chown -R USER:GROUP /var/run/rtc_client (code=exited, status=0/SUCCESS)
  Process: 38194 ExecStartPre=/bin/mkdir -p /var/run/rtc_client (code=exited, status=0/SUCCESS)

Qualquer ajuda é muito apreciada!

    
por S4rg0n 23.06.2016 / 10:27

1 resposta

0

A razão pela qual seu serviço está parando está no log que você forneceu:

/bin/bash rtc_client.sh start (code=exited, status=0/SUCCESS)

Seu script rtc_client.sh está saindo com um status SUCESSO. Você deve investigar seu script para ver por que ele não continua funcionando continuamente.

    
por 24.06.2016 / 18:18