Last active
July 7, 2019 08:41
-
-
Save hskang9/4def7c5d3e83cfcb92f2ed4d83ce9441 to your computer and use it in GitHub Desktop.
failsafe script daemon for systemctl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to setup | |
# 1. sudo vi /lib/systemd/system/{service name}.service and copy/paste this code as a starter | |
# | |
# 2. Configure log folders and user to execute the command and give access with following commands | |
# sudo chmod 755 /lib/systemd/system/{service name}.service | |
# | |
# 3. Configure systemctl to register the service in the system as start script with `enable` | |
# sudo systemctl enable {service name}.service | |
# | |
# 4. `start` service to test registered service scripts | |
# sudo systemctl start {service name} | |
# | |
# 5. Restart node and check process happening in each port | |
# lsof -i | |
# | |
# 6. kill process and test if the script still works | |
# kill {pid found in port from lsof -i command} | |
[Unit] | |
Description=command for running the cosmos node after restart. | |
ConditionPathExists=/home/ubuntu/go/bin/gaiad | |
After=network.target | |
[Service] | |
Type=simple | |
User=ubuntu | |
Restart=on-failure | |
RestartSec=10 | |
startLimitIntervalSec=60 | |
WorkingDirectory=/home/ubuntu/go/src/github.com | |
ExecStart= /home/ubuntu/go/bin/gaiad start --home=/home/ubuntu/.gaiad &> gaia2.log & NODE1_PID=$! | |
PermissionStartOnly=true | |
ExecStartPre=mkdir -p /var/log/cosmos | |
ExecStartPre=chown syslog:adm /var/log/cosmos | |
ExecStartPre=chmod 755 /var/log/cosmos | |
StandardOutput=syslog | |
StandardError=syslog | |
SyslogIdentifier=cosmos | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo journalctl -f -u cosmos-failsafe.service
Is what we have to run now