Skip to content

Commit

Permalink
EB: Replace restart-app cron with systemd timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed May 6, 2024
1 parent 8f7b990 commit 8bb9105
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .ebextensions/30-restart.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,35 @@ files:
#!/bin/bash -ex
kill -SIGUSR1 $(cat /var/pids/web.pid)

/etc/cron.d/restart:
/etc/systemd/system/restart-app.service:
mode: "000644"
owner: root
group: root
content: |
@daily root /opt/restart-app
[Unit]
Description="Service that runs /opt/restart-app"
Requires=restart-app.timer
[Service]
Type=simple
ExecStart=/opt/restart-app

/etc/systemd/system/restart-app.timer:
mode: "000644"
owner: root
group: root
content: |
[Unit]
Description="Timer for restart-app.service"
[Timer]
Unit=restart-app.service
OnCalendar=daily
RandomizedDelaySec=30m
[Install]
WantedBy=timers.target

container_commands:
"01-enable-timer":
command: |
systemctl daemon-reload
systemctl enable restart-app.timer
systemctl start restart-app.timer

0 comments on commit 8bb9105

Please sign in to comment.