Skip to content
Snippets Groups Projects
Commit 98fc82fe authored by David Schmitz's avatar David Schmitz
Browse files

systemd integration for DEBIAN/UBUNTU; added mail notification on failure

parent 8ecc60ec
No related branches found
No related tags found
No related merge requests found
...@@ -73,8 +73,9 @@ Dockerfile* ...@@ -73,8 +73,9 @@ Dockerfile*
runfod-*.sh runfod-*.sh
supervisord.conf supervisord.conf
fod-gunicorn.service systemd/fod-gunicorn.service
fod-celeryd.service systemd/fod-celeryd.service
systemd/fod-status-email-user@.service
############################################################################# #############################################################################
############################################################################# #############################################################################
......
...@@ -221,17 +221,24 @@ else ...@@ -221,17 +221,24 @@ else
# #
cp -f "$fod_dir/fod-gunicorn.service.dist" "$fod_dir/fod-gunicorn.service" fod_systemd_dir="$fod_dir/systemd"
sed -i "s#/srv/flowspy#$fod_dir#" "$fod_dir/fod-gunicorn.service" cp -f "$fod_systemd_dir/fod-gunicorn.service.dist" "$fod_systemd_dir/fod-gunicorn.service"
sed -i "s#/srv/flowspy#$fod_dir#" "$fod_systemd_dir/fod-gunicorn.service"
cp -f "$fod_systemd_dir/fod-celeryd.service.dist" "$fod_systemd_dir/fod-celeryd.service"
sed -i "s#/srv/flowspy#$fod_dir#" "$fod_systemd_dir/fod-celeryd.service"
cp -f "$fod_systemd_dir/fod-status-email-user@.service.dist" "$fod_systemd_dir/fod-status-email-user@.service"
sed -i "s#/srv/flowspy#$fod_dir#" "$fod_systemd_dir/fod-status-email-user@.service"
cp -f "$fod_dir/fod-celeryd.service.dist" "$fod_dir/fod-celeryd.service"
sed -i "s#/srv/flowspy#$fod_dir#" "$fod_dir/fod-celeryd.service"
if [ "$install_systemd_services" = 1 ]; then if [ "$install_systemd_services" = 1 ]; then
echo 1>&2 echo 1>&2
echo "Install_systemd_services" 1>&2 echo "Install_systemd_services" 1>&2
echo 1>&2 echo 1>&2
cp -f "$fod_dir/fod-gunicorn.service.dist" "$fod_dir/fod-celeryd.service.dist" "/etc/systemd/system/" #cp -f "$fod_systemd_dir/fod-gunicorn.service" "$fod_systemd_dir/fod-celeryd.service" "/etc/systemd/system/"
cp -v -f "$fod_systemd_dir/fod-gunicorn.service" "$fod_systemd_dir/fod-celeryd.service" "$fod_systemd_dir/fod-status-email-user@.service" "/etc/systemd/system/" 1>&2
systemctl daemon-reload
sleep 5 sleep 5
SYSTEMD_COLORS=1 systemctl status fod-gunicorn | cat SYSTEMD_COLORS=1 systemctl status fod-gunicorn | cat
......
...@@ -5,6 +5,8 @@ Description=Firewall-On-Demand (FoD) celeryd (back-end) ...@@ -5,6 +5,8 @@ Description=Firewall-On-Demand (FoD) celeryd (back-end)
#After=network.target auditd.service #After=network.target auditd.service
Requires=fod-gunicorn.service redis-server.service Requires=fod-gunicorn.service redis-server.service
OnFailure=fod-status-email-user@%n.service
[Service] [Service]
#Type=forking #Type=forking
......
...@@ -5,6 +5,8 @@ Description=Firewall-On-Demand (FoD) gunicorn (front-end) ...@@ -5,6 +5,8 @@ Description=Firewall-On-Demand (FoD) gunicorn (front-end)
After=network.target auditd.service After=network.target auditd.service
Requires=fod-celeryd.service redis-server.service Requires=fod-celeryd.service redis-server.service
OnFailure=fod-status-email-user@%n.service
[Service] [Service]
#Type=forking #Type=forking
......
[Unit]
Description=status email for %i to user
[Service]
Type=oneshot
WorkingDirectory=/srv/flowspy
ExecStart=/srv/flowspy/systemd/fod-systemd-email fod %i
User=nobody
Group=systemd-journal
#!/bin/bash
/usr/sbin/sendmail -t <<ERRMAIL
To: $1
From: systemd <root@$HOSTNAME>
Subject: $2
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
$(systemctl status --full "$2")
ERRMAIL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment