1

I run my script(socket) as daemon with init-script :

   #!/bin/bash



### BEGIN INIT INFO
 # Provides:          sock_serv
 # Required-Start:    $local_fs $syslog $remote_fs
 # Required-Stop:     $local_fs $syslog $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: sock_servservice
 # Description:       Run sock_serv service
 ### END INIT INFO

 # Carry out specific functions when asked to by the system
 case "$1" in
   start)
     echo "Starting sock_serv..."
     if sudo -u root bash -c 'cd ~/mypath/ && python3 sock_serv.py &> /dev/null &' ; then
       echo "OK"
     else
       echo "Error: can't start "
     fi
   ;;
stop)
   echo "Stopping sock_serv..."
   if sudo -u root bash -c 'cd ~/mypath/ && python3 stop_sock_serv.py &>/dev/null &'; then
   # sleep 2
      echo "OK"
   else
      echo "Error: can't stop "
   fi
   ;;
   *)
echo "Usage: /etc/init.d/sock_serv {start|stop}"
exit 1
;;
esac

I use in sock_serv loop wiht Module Select to receive Message from different client.

I can run my sock_serv, but after hours the sock_serv listen to any port( is stoped)

when I run service sock_serv status bevor and after sock_serv is stoped I get :

     sock_serv.service - LSB: sock_serv service
     Loaded: loaded (/etc/init.d/sock_serv; generated)
     Active: active (exited) since Sat 2019-10-12 16:06:56 CEST; 23h ago
     Docs: man:systemd-sysv-generator(8)
     Tasks: 0 (limit: 2301)
     Memory: 0B
     CGroup: /system.slice/sock_serv.service


    Oct 12 18:08:10 sam sudo[1042]: pam_unix(sudo:session): session closed for user root
   Oct 12 18:08:10 sam sudo[1045]:     root : TTY=unknown ; PWD=/root/mypath; USER=root ; COMMAND=/root/mypath/otherScript.py 
   Oct 12 18:08:10 sam sudo[1045]: pam_unix(sudo:session): session opened for user root by (uid=0)

   Oct 12 18:08:10 sam sudo[1045]: pam_unix(sudo:session): session closed for user root

i want that the sock_serv still running continously. Thanks

5
  • I would try to figure out why sock_serv.py is exiting. Commented Oct 13, 2019 at 15:30
  • If that's not an option, you automatically restart it when it crashes. One way is to use systemd with Restart=on-failure. Commented Oct 13, 2019 at 15:32
  • thanks for your answer,. Where I put this line Restart=on-failure ? Commented Oct 13, 2019 at 16:07
  • @Mikel , I check logfile nothing found, just what i get from service sock_serv status Commented Oct 13, 2019 at 16:10
  • I found this error Oct 12 17:05:51 sam kernel: [ 10.447716] wireguard: module verification failed: signature and/or required key missing - tainting kernel in kernel.log at same when myservice is exited Commented Oct 13, 2019 at 17:19

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.