Skip to content

Commit a351e00

Browse files
author
shanur-marsplay
committed
some systemd scripts for automating redundant tasks
1 parent f686910 commit a351e00

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ssh-configs/ssh-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# whatever name you want to ssh it from your local machine
1+
# whatever name you want to ssh it from your local machine, can be anything call it foo
22
Host prod.backend.marsplay
33

44
# use the ip address of the remote server, using dns in this case

systemd/marsplay.service

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# service file for autostarting your docker builds on system reboot
2+
# I wrote this file so that in case of server crashes anyone can simply reboot the system and get the system running again
3+
# I paired this up with aws system checks, In case of failed system check I applied the restart policy. So your system never goes
4+
# out for more than 2 minutes even in case of seve crashes.
5+
6+
# /etc/systemd/system/docker-compose-app.service
7+
8+
[Unit]
9+
Description=Docker Compose Application Service
10+
Requires=docker.service # This will start docker service, equivalent of calling sudo service start docker, yes it runs on root priviledges
11+
After=docker.service # once the docker service has started we run the remaining
12+
13+
[Service]
14+
WorkingDirectory=/home/ec2-user/marsplay-api/docker/prod #The location of docker-compose file
15+
ExecStart=/usr/local/bin/docker-compose up #start script,
16+
ExecStop=/usr/local/bin/docker-compose down #before system shutdown
17+
TimeoutStartSec=0
18+
Restart=on-failure #restart policy in case it was shutdown
19+
StartLimitIntervalSec=60
20+
StartLimitBurst=3
21+
22+
[Install]
23+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)