Upstart script for DeepDetect

Create upstart config /etc/init/deepdetect.conf

description "DeepDetect"

start on filesystem or runlevel [2345]
stop on run level [!2345]

respawn
respawn limit 3 12

script
    exec /usr/bin/deepdetect.sh
end script

pre-start script
    echo "command_deepdetect_starting START : $(date)" >> /var/log/deepdetect.log
end script

pre-stop script
    rm /var/run/command_deepdetect_starting.pid
    echo "command_deepdetect_starting STOP : $(date)" >> /var/log/deepdetect.log
end script

Create BASH file /usr/bin/deepdetect.sh

#!/usr/bin/env bash
cd /home/ubuntu/deepdetect/build/main
sleep 1

sudo ln /dev/null /dev/raw1394
sleep 2

./dede --host 0.0.0.0

or put to logs file

#!/usr/bin/env bash
cd /home/ubuntu/deepdetect/build/main
sleep 1

sudo ln /dev/null /dev/raw1394
sleep 2

./dede --host 0.0.0.0 >> /var/log/deepdetect_info.log

Then:

sudo chmod +x /usr/bin/deepdetect.sh

for testing in my local pc

#!/usr/bin/env bash
cd /home/tamnguyen/Projects/deepdetect/build/main
sleep 1

sudo ln /dev/null /dev/raw1394
sleep 2

./dede --host 0.0.0.0

To check syntax

init-checkconf /etc/init/deepdetect.conf

if ok, you will see result:

File /etc/init/deepdetect.conf: syntax ok

To start service

sudo service deepdetect start

if ok, you see:

deepdetect start/running, process 5382

To stop service

sudo service deepdetect stop

If you see errors:

./dede: error while loading shared libraries: libcudart.so.7.5: cannot open shared object file: No such file or directory

To resolve:

sudo ldconfig /usr/local/cuda/lib64

Enjoy šŸ˜€