Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding smtp monitor restart scripts #11

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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