Running the "service service_name status" command gives three different types of output when three different service_names are used. I tried with atftpd, apache2, and isc-dhcp-server, as shown below.

user@host:~$ service atftpd status
Usage: /etc/init.d/atftpd {start|stop|restart|reload|force-reload}
user@host:~$ service apache2 status
Apache2 is running (pid 1103).
user@host:~$ service isc-dhcp-server status
isc-dhcp-server start/running, process 5696

Could this be because atftpd has not been converted to Upstart?

The status for isc-dhcp-server shows "start/running" which indicates it has been converted to use Upstart. I would've thought apache2 would have been converted to Upstart already. If it has then why does it not display "start/running"?


I think I may understand a bit more after doing some digging within Ubuntu and also Googling stuff. All services have not been ported to Upstart.

ls -l /etc/init.d/

The above command lists all files but we are interested in a few.

-rwxr-xr-x 1 root root 7621 Feb  6  2012 apache2
-rwxr-xr-x 1 root root 1511 Oct 17  2011 atftpd
lrwxrwxrwx 1 root root   21 Sep 14 10:57 isc-dhcp-server -> /lib/init/upstart-job

As you can see, apache2 and atftpd have not been converted to Upstart yet while isc-dhcp-server had. Let's list files in another directory.

ls -l /etc/init

Again lots of files are listed but we are interested in just one:

-rw-r--r-- 1 root root 1704 Sep 14 10:56 isc-dhcp-server.conf

This confirms that isc-dhcp-server has been converted to Upstart but apache2 and atftpd have not.

But now the question is whether to use the old invoke-rc.d or /etc/init.d/ commands to start/stop/etc. services, or use service command, or use initctl (Upstart) command? The answer I understand best is to always use the service command. Based on how init files are configured in /etc/init.d/, service will either use the initctl (or start or stop) for services converted to Upstart and use the older /etc/init.d/ for services that have not been converted. As users we don't have to worry and always use service. Disclaimer: I tested this only in Ubuntu 12.04.

  • Shh... I don't think it matters which you use. I still tend to type sudo /etc/init.d/networking restart from muscle memory. I think the thing to take away, is always use service when you are scripting. That way if the same service is ever converted to upstart later, you can be sure that your script will still work. In a perfect world, everything would have native Upstart jobs and we could do away with the entire /etc/init.d structure. I wouldn't hold my breath though! – Mark Russell Oct 17 '12 at 22:26

Correct, this is because you are checking the status of two types of service, one is Upstart ntive (isc-dhcp-server) and the other two are System V style init scripts. One of these SysV scripts (atftpd) does not support the status command. The status sub-command is not a mandatory init script command, unlike start and stop.

The reason why Apache has not been converted to Upstart is in how it forks off processes. In short, Upstart uses the kernel ptrace() facility to follow forks, but it only tracks forks and not exits, it assumes the parent process is gone. To make a long story short, this is not compatible with the way certain daemons handle forking, such as apache2 and postfix.

These two old bugs, get to the technical heart of the matter.

Some folks have had a little success writing their own Upstart jobs and starting Apache with a "no detach" option, but this is unsupported and if you're not careful, a package upgrade could clobber your changes. Init scripts and Upstart jobs are not intended to be edited by the user. Dpkg considers this a conflict and will prompt you when upgrading. If you don't have a specific reason to switch Apache to a native Upstart job, I would stick with the init script. Note: the way to properly modify Upstart jobs is to create a .override file [see man 5 init].

In the future, Upstart may switch from ptrace() to using cgroups to manage process groups, which would remove this type of problem. But that's still over the horizon, I believe.

  • Off topic: Do you know if systemd is able to handle the type of forking that apache2 and postfix use? – Code Ghar Oct 17 '12 at 22:30
  • I suspect that systemd works very well with something like apache, but I don't know personally. I think systemd was correct to (afaiui) emphasize compatibility. In the end I still find upstart to be a more flexible and elegant solution than the dependency based boot we get with systemd. Admittedly, I'm a bit biased. – Mark Russell Oct 18 '12 at 3:27
  • I also think that even if a service is a SysV-init job, there is absolutely a way to use Upstart to make your boot dependencies work. It just takes some understanding how how event-based boot occurs. The Upstart Cookbook is a good place to start: upstart.ubuntu.com/cookbook – Mark Russell Oct 18 '12 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.