mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 22:12:53 +00:00
feat: add systemd service examples
This commit is contained in:
committed by
Rainer Killinger
parent
053a6ce23f
commit
c54aa25f34
1
config/RECIPIENTS
Normal file
1
config/RECIPIENTS
Normal file
@@ -0,0 +1 @@
|
||||
your.mail@address.heres
|
||||
23
systemd/stapps-proxy.service
Normal file
23
systemd/stapps-proxy.service
Normal file
@@ -0,0 +1,23 @@
|
||||
[Unit]
|
||||
Description=@openstapps/proxy
|
||||
Documentation=https://gitlab.com/openstapps/proxy
|
||||
After=network-online.target
|
||||
Requires=network-online.target
|
||||
OnFailure=stapps-unit-status-mail@%n.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/env docker run --rm --net="host" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /opt/stapps-compose/proxy/ssl/chain.crt:/etc/nginx/certs/ssl.crt \
|
||||
-v /opt/stapps-compose/proxy/ssl/private.key:/etc/nginx/certs/ssl.key \
|
||||
-v /opt/stapps-compose/proxy/static:/static \
|
||||
registry.gitlab.com/openstapps/proxy/master
|
||||
StartLimitBurst=2
|
||||
StartLimitIntervalSec=100s
|
||||
Restart=always
|
||||
RestartSec=20s
|
||||
WorkingDirectory=/opt/stapps-compose/proxy
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
22
systemd/stapps-unit-status-mail.sh
Executable file
22
systemd/stapps-unit-status-mail.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
MAILTO=`cat ../config/RECIPIENTS`
|
||||
UNIT=$1
|
||||
|
||||
EXTRA=""
|
||||
for e in "${@:2}"; do
|
||||
EXTRA+="$e"$'\n'
|
||||
done
|
||||
|
||||
UNITSTATUS=$(systemctl status --lines=50 $UNIT)
|
||||
|
||||
ssmtp $MAILTO <<EndOfMessage
|
||||
To:$MAILTO
|
||||
Subject:Status mail for unit: $UNIT
|
||||
|
||||
Status report for unit: $UNIT
|
||||
$EXTRA
|
||||
|
||||
$UNITSTATUS
|
||||
EndOfMessage
|
||||
|
||||
echo -e "Status mail sent to: $MAILTO for unit: $UNIT"
|
||||
7
systemd/stapps-unit-status-mail@.service
Normal file
7
systemd/stapps-unit-status-mail@.service
Normal file
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Unit Status Mailer Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/opt/stapps-compose/proxy/systemd/stapps-unit-status-mail.sh %I "Hostname: %H" "Machine ID: %m" "Boot ID: %b"
|
||||
Reference in New Issue
Block a user