I created a script service called "puma.service" in /etc/systemd/system/ with the following contents:
[Unit] Description=Puma HTTP Server After=network.target [Service] Type=simple User=ubuntu WorkingDirectory=/home/username/appdir/current ExecStart=/bin/bash -lc "/home/username/appdir/current/sbin/puma -C /home/username/appdir/current/config/puma.rb /home/username/appdir/current/config.ru" Restart=always [Install] WantedBy=multi-user.target
I turned on the service and when I started, I get the following log from systemctl:
● puma.service - Puma HTTP Server Loaded: loaded (/etc/systemd/system/puma.service; enabled; vendor preset: enabled) Active: inactive (dead) (Result: exit-code) since Wed 2016-12-14 10:09:46 UTC; 12min ago Process: 16889 ExecStart=/bin/bash -lc cd /home/username/appdir/current && bundle exec puma -C /home/username/appdir.. Main PID: 16889 (code=exited, status=127) Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: puma.service: Main process exited, code=exited, status=127/n/a Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: puma.service: Unit entered failed state. Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: puma.service: Failed with result 'exit-code'. Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: puma.service: Service hold-off time over, scheduling restart. Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: Stopped Puma HTTP Server. Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: puma.service: Start request repeated too quickly. Dec 14 10:09:46 ip-172-31-29-40 systemd[1]: Failed to start Puma HTTP Server.
Although, when I provide the command in the SSH terminal, the server starts up and works fine. Are there any changes I have to make to the service file?
Note:
- I changed the dirnames for your convenience.
- I did some research, and the reason for status 127 is related to an executable that is not in the way. But, I think this is not a problem.
Can you shed some light?
source share