Run DxSpider as service on the Raspbian

How to run dxspider as service.

Create init script with name dxpider as root user in the below path /etc/init.d/

#!/bin/sh
### BEGIN INIT INFO
# Provides:             dxspider
# Required-Start:       $all
# Required-Stop:        $all
# Default-Start:        2 3 5
# Default-Stop:         0 1 6
# Short-Description:    Dxspider
### END INIT INFO
#
# Created by SV5FRI
# Email: sv5fri@gmail.com
#
##############################
NAME=dxspider
DESC=dxspider

PID=`ps -A |grep perl|awk '{print $1}'`

set -e

pidfile=/spider/local/cluster.lck

. /lib/lsb/init-functions

RETVAL=0

# See how we were called.

  start()
   {
        echo  "Starting DxSpider Server..."
        /bin/su - sysop -c "/usr/bin/perl -w /spider/perl/cluster.pl" > /dev/tty3&
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/dxspider
        echo
        return $RETVAL
   }

  stop()
   {
        echo "Stopping DxSpider Server..."
        pkill -F  $pidfile
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/dxspider
        echo
        return $RETVAL
        }

  restart()
   {
       stop
       start
   }

case "$1" in
  start)
     start
  ;;

  stop)
    stop
  ;;

  restart)
    restart
  ;;
  status)
        if [ -f "$pidfile" ];
         then
                echo "Dxspider is running with pid: $PID"
         else
                echo "Dxspider is stopped..."
#        RETVAL=$?
      fi
  ;;

  *)
       echo $"Usage: $0 {start|stop|restart|status}"
        exit $?
        ;;
esac
exit $?

 

Change permissions

chmod +x dxspider

Remove or disable line from /etc/inittab

DX:2345:respawn:/bin/su -c "/usr/bin/perl -w /spider/perl/cluster.pl" sysop >/dev/tty6

Start dxspider

/etc/init.d/dxspider start

Stop dxspider

/etc/init.d/dxspider stop

Check if running dxspider

/etc/init.d/dxspider status

If you need help please contact with me

Good luck

Share