I have a service in Ubuntu 16.04 like below:
[Unit] Description=Jboss Application Server After=network.target [Service] Type=forking Environment=JAVA_HOME=/opt/jdk/jdk1.8.0_151 ExecStart=/opt/server/jboss/jboss-4.0.5.GA/bin/run.sh ExecStop=/opt/server/jboss/jboss-4.0.5.GA/bin/shutdown.sh User=jboss Group=jboss UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target
When the service starts it does not exit and does not return the prompt.
In the above server the Type=forking means systemd is waiting for the process to fork itself and for the parent process to end, which it takes as an indication that the process has started successfully. The process was not doing that as it remained in the foreground and so systemctl start will hang indefinitely or until the processes crashes.
There are different types of services under systemd. Following are the available ones:
simple - A long running process that does not background its self and stays attached to the shell.
forking - A typical daemon that forks itself detaching it from the process that ran it, effectively backgrounding itself.
oneshot - A short lived process that is expected to exit.
dbus - Like simple, but notification of processes startup finishing is sent over dbus.
notify - Like simple, but notification of processes startup finishing is sent over inotify.
idle - Like simple, but the binary is started after the job has been dispatched.
So, in the above case if we do Type=simple, which is the default service type.
In this mode systemd does not wait for the processes to finish starting up.
In the above server the Type=forking means systemd is waiting for the process to fork itself and for the parent process to end, which it takes as an indication that the process has started successfully. The process was not doing that as it remained in the foreground and so systemctl start will hang indefinitely or until the processes crashes.
There are different types of services under systemd. Following are the available ones:
simple - A long running process that does not background its self and stays attached to the shell.
forking - A typical daemon that forks itself detaching it from the process that ran it, effectively backgrounding itself.
oneshot - A short lived process that is expected to exit.
dbus - Like simple, but notification of processes startup finishing is sent over dbus.
notify - Like simple, but notification of processes startup finishing is sent over inotify.
idle - Like simple, but the binary is started after the job has been dispatched.
So, in the above case if we do Type=simple, which is the default service type.
In this mode systemd does not wait for the processes to finish starting up.
Comments
Post a Comment