Astra. Autorun

Init.d script

Used almost in all Linux distributions: Debian, Ubuntu, CentOS, RedHat, Fedora

Create script /etc/init.d/astra:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          astra
# Required-Start:    $network $syslog $named
# Required-Stop:     $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop astra
### END INIT INFO

set -e

if [ -z "$1" ] ; then
    echo "Usage: $0 [start|stop|restart]"
    exit 0
fi

if [ "$1" = "start" ] ; then
    ulimit -n 65536
    /usr/bin/astra --pid /var/run/astra.pid --log /var/log/astra.log -c /etc/astra/astra.conf -p 8000 --daemon
elif [ "$1" = "stop" ] ; then
    kill `cat /var/run/astra.pid`
elif [ "$1" = "restart" ] ; then
    $0 stop
    sleep 1
    $0 start
fi

Set an execute permission for the script chmod +x /etc/init.d/astra

Turn on autorun:

Commands to control daemon:

Monit

Monit is an utility for managing and monitoring system services. Monit executes application on system startup and restarts it after an unexpected exit.

Install monit:

sudo apt-get install monit

In the configuration file /etc/monit/monitrc set next options:

set daemon 1
  with start delay 1

set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state

set httpd port 2812 and
  use address localhost
  allow localhost

include /etc/monit/conf.d/*

After you save changes restart monit:

/etc/init.d/monit restart

Create configuration file /etc/monit/conf.d/astra.conf:

check process astra with pidfile /var/run/astra.pid
    start program = "/bin/sh -c 'ulimit -n 65536; /usr/bin/astra --pid /var/run/astra.pid --log /var/log/astra.log -c /etc/astra/astra.conf -p 8000 --daemon'"
    stop program = "/bin/sh -c 'kill `cat /var/run/astra.pid`'"

Systemd

Systemd used in TBS MOI Pro/Plus.

Create configuration file /lib/systemd/system/astra.service:

[Unit]
Description=Astra
After=network.target

[Service]
TimeoutStartSec=10
LimitNOFILE=65536
ExecStartPre=/bin/mkdir -p /etc/astra
ExecStart=/usr/bin/astra -c /etc/astra/astra.conf -p 8000 --log /var/log/astra.log
ExecStop=/bin/kill $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

Next commands used to manage service:

Back: Home > Docs
?