I have the following script in the /etc/systemd/system/
folder.
# Start the ruby on rails app on boot
[Unit]
Description=Start Ruby Online Ordering Application
[Service]
Type=simple
RemainAfterExit=yes
Username=root
PIDFile=/home/deviant/www/tmp/pids/server.pid
WorkingDirectory=/home/deviant/www
ExecStart=/home/deviant/www/run.sh
TimeoutSec=300
[Install]
WantedBy=multi-user.target
with a permission of -rw-r--r-- 1 root root
The run.sh script contains
#!/bin/sh
service httpd stop
rails s -p 80 -d
with a permission of -rwxrwxr-x 1 root root
In short, it is supposed to start a Ruby application upon restart of a server, however, it does not appear to be working.
Where can I check to see system error logs? What would cause it NOT to start upon a server restart?
I tried changing the script to:
[Service]
Type=oneshot
RemainAfterExit=yes
PIDFile=/home/deviant/www/tmp/pids/server.pid
WorkingDirectory=/home/deviant/www
ExecStart=/home/deviant/www/run.sh
TimeoutSec=300
And I now get on systemctl enable....
Unknown lvalue 'Username' in section 'Service' ...has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.
I'm not sure what this even means. What does it mean?
Type=simple
, but it looks like yourrun.sh
script will start two processes and then exit. This makessystemd
think that your service failed, and it will kill off thehttpd
andrails
child processes, with the assumption that they are just garbage left by the failed service.Type=simple
is for processes that won't exit until the administrator runs the command to stop the service. – telcoM Jan 23 '20 at 14:25