Skip to content

Instantly share code, notes, and snippets.

@hskang9
Last active July 7, 2019 14:55
Show Gist options
  • Save hskang9/49717c795b1ceb25a32696fb9ff10f7b to your computer and use it in GitHub Desktop.
Save hskang9/49717c795b1ceb25a32696fb9ff10f7b to your computer and use it in GitHub Desktop.
Thundertoken failsafe service
# How to setup
# 1. Prepare thunder.json with allocated coinbase address generated from /home/ubuntu/thundercore-localchain/build/bin/puppeth
#
# 2. Initialize thunder token with init command
#
# 3. Specify etherbase (thundertoken address as an ethereum address) and add it as option --etherbase on ExecStart command.
#
# 3. sudo vi /lib/systemd/system/{service name}.service and copy/paste this code as a starter
#
# 4. Configure log folders and user to execute the command and give access with following commands
# sudo chmod 755 /lib/systemd/system/{service name}.service
#
# 5. Configure systemctl to register the service in the system as start script with `enable`
# sudo systemctl enable {service name}.service
#
# 6. `start` service to test registered service scripts
# sudo systemctl start {service name}
#
# 7. Restart node and check process happening in each port
# lsof -i
#
# 8. 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/thundercore-localchain/build/bin
After=network.target
[Service]
Type=simple
User=ubuntu
Restart=on-failure
RestartSec=10
startLimitIntervalSec=60
WorkingDirectory=/home/ubuntu/thundercore-localchain/build/bin
ExecStart= /home/ubuntu/thundercore-localchain/build/bin/thunderlocal --datadir /home/ubuntu/.thundertoken --networkid 3606 --rpc --rpcport "8545" --rpccorsdomain "*" --rpcapi "db,eth,net,miner,web3,personal" --nodiscover --mine
PermissionStartOnly=true
ExecStartPre=mkdir -p /var/log/thunder
ExecStartPre=chown syslog:adm /var/log/thunder
ExecStartPre=chmod 755 /var/log/thunder
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=thunder
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment