Skip to content

Commit

Permalink
adding smtp monitor restart scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwinship committed Jun 12, 2024
1 parent 77630b4 commit fc7cafe
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
.DS_Store?
.vscode
.idea

environment/data
environment/config.inc.php
Expand Down
17 changes: 17 additions & 0 deletions docs/Sphinx-guides/source/developerGuide/localEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ smtp_port = 25
smtp_suppress_cert_check = On
```
#### Setting up a systemd service and timer to restart the SMTP service automatically if it goes down:
Copy ppr-ojs/environment/monitoring/monitor-smtp.service and monitor-smtp.timer to /etc/systemd/system/ on the machine the smtp server is running
Copy ppr-ojs/environment/monitoring/smtp-monitor.sh to your home directory on the machine the smtp server is running and give it execution permissions
The default directory is /home/core/smtp-monitor.sh but can be changes by editing the monitor-smtp.service file
Start the service:
```
sudo systemctl start monitor-smtp.timer
```
A log will be generated and can be viewed by:
```
cat /tmp/smtp-monitor
```
## Clean the data directories
To start the OJS application fresh, you will need to clean the DB and OJS files within the data directory.
Expand Down
6 changes: 6 additions & 0 deletions environment/monitoring/monitor-smtp.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Monitors SMTP docker container and restarts if not running

[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c '/home/core/smtp-monitor.sh >> /tmp/smtp-monitor'
5 changes: 5 additions & 0 deletions environment/monitoring/monitor-smtp.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=Run monitor-smtp.service every 10 minutes

[Timer]
OnCalendar=*:0/10
11 changes: 11 additions & 0 deletions environment/monitoring/smtp-monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

CONTAINER_NAME=iqss-smtp-ojs

if docker ps | grep -q $CONTAINER_NAME; then
echo "$(date -u) running"
else
echo "$(date -u) not running"
#docker start $CONTAINER_NAME
docker run --rm -itd --name $CONTAINER_NAME -p 1080:1080 -p 1025:1025 --env MAILDEV_SMTP_PORT=1025 --env MAILDEV_WEB_PORT=1080 --env MAILDEV_MAIL_DIRECTORY=/mail --mount type=tmpfs,destination=/mail maildev/maildev:2.0.5
fi

0 comments on commit fc7cafe

Please sign in to comment.