Another attempt at crash mailing

This commit is contained in:
Asaf Gartner 2021-09-04 21:59:03 +03:00
parent 67ff97b27d
commit 307a122518
7 changed files with 6 additions and 15 deletions

View File

@ -5,5 +5,5 @@ if [ $SERVICE_RESULT == "success" ]; then
fi
/home/hmn/hmn/adminmailer/adminmailer "[$1] Status changed" <<ERRMAIL
$(service "$1" status)
$(systemctl status --full "$1")
ERRMAIL

View File

@ -28,7 +28,7 @@ LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
ExecStopPost=status-email@%n.service
ExecStopPost=/home/hmn/hmn/server/adminmailer.sh %n
[Install]
WantedBy=multi-user.target

View File

@ -10,7 +10,7 @@ ExecStart=/home/hmn/hmn/cinera/start.sh
ExecStop=/home/hmn/hmn/cinera/stop.sh
PIDFile=/home/hmn/hmn/cinera/data/cinera.pid
Restart=always
ExecStopPost=status-email@%n.service
ExecStopPost=/home/hmn/hmn/server/adminmailer.sh %n
[Install]
WantedBy=multi-user.target

View File

@ -8,7 +8,7 @@ Group=hmn
ExecStart=/home/hmn/bin/hmn
Restart=always
TimeoutStopSec=15
ExecStopPost=status-email@%n.service
ExecStopPost=/home/hmn/hmn/server/adminmailer.sh %n
[Install]
WantedBy=multi-user.target

View File

@ -199,11 +199,9 @@ if [ $checkpoint -lt 100 ]; then
cp /home/hmn/hmn/server/caddy.service /etc/systemd/system/caddy.service
cp /home/hmn/hmn/server/hmn.service /etc/systemd/system/hmn.service
cp /home/hmn/hmn/server/cinera.service /etc/systemd/system/cinera.service
cp /home/hmn/hmn/server/status-email@.service /etc/systemd/system/status-email@.service
chmod 644 /etc/systemd/system/caddy.service
chmod 644 /etc/systemd/system/hmn.service
chmod 644 /etc/systemd/system/cinera.service
chmod 644 /etc/systemd/system/status-email@.service
cp /home/hmn/hmn/server/logrotate /etc/logrotate.d/hmn

View File

@ -1,8 +0,0 @@
[Unit]
Description=Status email for %i
[Service]
Type=oneshot
ExecStart=/home/hmn/hmn/server/adminmailer.sh %i
User=root
Group=systemd-journal

View File

@ -365,7 +365,8 @@ func SeedFromFile(seedFile string, afterMigration types.MigrationVersion) {
seedFile,
)
fmt.Println("Running command:", cmd)
if err = cmd.Run(); err != nil {
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Print(string(output))
exitError, isExit := err.(*exec.ExitError)
if isExit {
panic(fmt.Errorf("failed to execute seed: %w\n%s", err, string(exitError.Stderr)))