(The default RestartSec= value is 100 ms.) In that case, your entire rvice unit would be: ĮxecStart=/home/rails/NodeJSserver/server.jsįor example, you could specify RestartSec=5 to specify a 5-second sleep before attempting to restart the service if it unexpectedly dies, to avoid hogging system resources by frequent restart attempts if your service keeps dying immediately after being restarted for some reason. The third option is to skip the forever command entirely and let systemd do the job of restarting the NodeJS process. So if you set another service to depend on this service, and then stop your NodeJS service manually, the other service won't stop automatically and will no doubt return errors when it cannot use your NodeJS service. Systemd will still remember whether the service was last set in a stopped or started state, though. That makes systemd just run the ExecStart= command when starting your service and ExecStop= when stopping it, and not care about anything else. If Type=forking does not work for you, then you could specify Type=oneshot with RemainAfterExit=yes. With this type, man rvice recommends using a PIDFile= option, so if your NodeJS server creates a PID file for itself (or you add options to the forever command to make it create one for it), you should let systemd know where it will be. Since the command you run with ExecStart= will exit as soon as the actual server is started, you cannot use the default Type=simple. After that, your actual NodeJS process will be dead, guaranteed. Can't have that." Since there is no KillMode= nor KillSignal= specified, systemd goes on with its defaults and sends a SIGTERM for any remaining processes in that control group, and if they don't stop in a timely manner, follows up with a SIGKILL. "So," thinks systemd, "not only did it fail, but it also left a mess after itself. But wait, the control group assigned for that service still has a running process in it. As soon as the forever start command completes, the shell running start.sh will exit.Īt that point, systemd considers this service as failed. That is the forever command: forever start starts the target command as a daemon, or in other words, in the background. But it looks like your start.sh only runs one command and then exits. That means systemd will expect the process that was started with ExecStart= to keep running as long as the service is running. Your service has no Type= specified in the section, so systemd assumes you meant Type=simple.
![visualsvn server cannot start service visualsvn server cannot start service](http://i.stack.imgur.com/pd8i8.png)
How do I figure out why my service failed to start? To show all installed unit files use 'systemctl list-unit-files'.
![visualsvn server cannot start service visualsvn server cannot start service](https://i.ytimg.com/vi/pKU9lJ4dmJw/maxresdefault.jpg)
Pass -all to see loaded but inactive units, too. SUB = The low-level unit activation state, values depend on unit type.ģ loaded units listed. LOAD = Reflects whether the unit definition was properly loaded.ĪCTIVE = The high-level unit activation state, i.e.
![visualsvn server cannot start service visualsvn server cannot start service](https://vorkbaard.nl/wp-content/uploads/2013/11/svn-11.png)
But when I try and run it as part of the service, I notice my nodeJS server isn't started. The file points to this ~]$ cat /home/rails/NodeJSserver/start.shįorever start /home/rails/NodeJSserver/server.js How do I figure out why a service is failing to start? I have created this service ~]$ sudo cat /usr/lib/systemd/system/rviceĮxecStart=/home/rails/NodeJSserver/start.shĮxecStop=/home/rails/NodeJSserver/stop.sh