Added 'sats.main' to manage all SATS debug (out) routines + added instance service to enable/disable
This commit is contained in:
parent
55755ab627
commit
3bca49214c
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=[::SATS::] Debugger (to %i)
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
User=pi
|
||||
Group=pi
|
||||
ExecStart=/usr/bin/git clone -b master ssh://smmp-server/satsd/git /service/debug;
|
||||
ExecStart=/bin/bash /service/debug/sats/main %i
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
# (1) Primary init.
|
||||
#--------------------------------------------------------#
|
||||
# (1) Get absolute folder #
|
||||
ROOT=$(dirname `realpath $0`);
|
||||
ROOT=`dirname $ROOT`;
|
||||
|
||||
# (2) Check config file #
|
||||
test ! -f $ROOT/com/config/sats && echo "Daemon not started" && exit 1;
|
||||
|
||||
# (3) Fetch BUFFERS #
|
||||
source $ROOT/com/config/sats;
|
||||
|
||||
# (4) Check required arguments
|
||||
test $# -lt 1 && echo -e "ERR: Missing argument\n\n\tSATS_ID\tThe id for the bash-socket\n" && exit 1;
|
||||
|
||||
|
||||
# (2) Start server in background
|
||||
#--------------------------------------------------------#
|
||||
# (1) Start server #
|
||||
$ROOT/com/launch sats $1 44441 44440 9999&
|
||||
|
||||
# (2) Save PID for later #
|
||||
SERV_PID=$!;
|
||||
|
||||
|
||||
# (3) Start daemons
|
||||
#--------------------------------------------------------#
|
||||
# (1) GPIO daemon #
|
||||
$ROOT/sats/gpio&;
|
||||
GPIO_PID=$!;
|
||||
|
||||
# (2) SYSTEMD daemon #
|
||||
$ROOT/sats/sysd&;
|
||||
SYSD_PID=$!;
|
||||
|
||||
|
||||
|
||||
# (4) Attach processes to itself
|
||||
#--------------------------------------------------------#
|
||||
trap "kill -9 $SERV_PID 2>/dev/null; kill -9 $GPIO_PID 2>/dev/null; kill -9 $SYSD_PID 2>/dev/null; exit 1;" INT;
|
||||
trap "kill -9 $SERV_PID 2>/dev/null; kill -9 $GPIO_PID 2>/dev/null; kill -9 $SYSD_PID 2>/dev/null; exit 1;" KILL;
|
Loading…
Reference in New Issue