If I run this command from terminal, it works fine:
bundle exec /home/ubuntu/.rbenv/shims/puma -C /var/www/html/mysite/config/puma.rb
But if I was to put that in ExecStart
in a systemd service unit file:
[Unit]
Description=Puma Application HTTP Server
After=network.target
[Service]
Type=simple
WorkingDirectory=/var/www/html/mysite
ExecStart=bundle exec /home/ubuntu/.rbenv/shims/puma -C /var/www/html/mysite/config/puma.rb
Restart=always
[Install]
WantedBy=multi-user.target
I will get error:
Executable path is not absolute: bundle exec /home/ubuntu/.rbenv/sh
I think it's complaining that the command must begin with absolute path instead of 'bundle exec'. So I try this:
ExecStart=/bin/bash -lc 'bundle exec /home/ubuntu/.rbenv/shims/puma -C /var/www/html/mysite/config/puma.rb'
Now when I run systemctl daemon-reload and systemctl start puma-mysite, I get this error:
Jan 03 00:07:53 ip-10-0-1-133 systemd[1]: puma-mysite.service: Start request repeated too quickly.
Jan 03 00:07:53 ip-10-0-1-133 systemd[1]: puma-mysite.service: Failed with result 'exit-code'.
Jan 03 00:07:53 ip-10-0-1-133 systemd[1]: Failed to start Puma Application HTTP Server.
It seems to be an issue with SystemD, for the command works outside of SystemD.