I'm running a service on a EC2 instance that should boot at start and whenever the script associated fails.
So I wrote the service like this:
[Unit]
Description=Test
[Service]
User=ubuntu
Type=simple
ExecStart=/usr/bin/ruby /home/ubuntu/main/test.rb
Restart=on-failure
RestartSec=1s
[Install]
WantedBy=multi-user.target
But when I kill the process or reboot the server, the service won't start. The service is enabled, and when I manually start it, it works as expected.
journelctl --unit=Test
give you?test.service - Test Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: enabled) Active: inactive (dead) since Mon 2023-01-09 16:49:21 UTC; 1min 32s ago Process: 35430 ExecStart=/usr/bin/ruby /home/ubuntu/main/test.rb (code=killed, signal=TERM) Main PID: 35430 (code=killed, signal=TERM) CPU: 20.558s