Upstart

On this page 7

Upstart is an event-based init system for Linux, created at Canonical and first shipped with Ubuntu 6.10 in 2006. As the process with PID 1, it started, stopped and supervised services by reacting to events such as a filesystem being mounted or a network interface coming up, instead of running scripts in a fixed order.

In the history of Linux system initialization, Upstart is the bridge between the sequential SysVinit model and the dependency-based design of systemd. It was the default on Ubuntu until version 15.04, served Red Hat Enterprise Linux 6 and early Fedora releases, and powered ChromeOS for many years. Development ended in 2014, so today it matters mainly for legacy systems and migration work.

How Upstart reacts to events

Upstart treats the boot process as a chain of events and job state changes. The kernel starts Upstart, which emits the startup event. Jobs configured to start on that event run, and each job in turn emits events such as starting, started, stopping and stopped, which can trigger further jobs.

This push model differs from SysVinit, where numbered scripts in a runlevel directory run strictly one after another. In Upstart, work starts as soon as its conditions are met, so independent services start in parallel and hot-plugged hardware can trigger jobs at any time, not only during boot.

The table below lists events that appear in most Upstart job files.

EventEmitted byTypical use
startupUpstart at bootStarting the very first jobs
filesystemThe mountall helperJobs that need all local filesystems
net-device-upNetwork scriptsServices that need a network interface
runlevelThe telinit compatibility layerEmulating SysV runlevels
started JOBUpstart after a job startsStarting dependent services
stopping JOBUpstart before a job stopsStopping services in the right order
Frequently used Upstart events

Job files and stanzas

Each Upstart service is described by a job file in /etc/init with the .conf extension. The file is made of stanzas, short keywords that define when the job runs, what it executes and how it is supervised. A minimal web service might contain start on (filesystem and net-device-up IFACE!=lo), stop on runlevel [016], respawn and exec /usr/sbin/mydaemon.

StanzaPurposeExample
start onEvent expression that starts the jobstart on started mysql
stop onEvent expression that stops the jobstop on runlevel [016]
exec or scriptCommand or shell block to runexec /usr/bin/app --foreground
respawnRestart the job if it diesrespawn limit 10 5
expectHow to follow forking daemonsexpect fork or expect daemon
taskJob runs once and finishesCleanup or setup steps
pre-start and post-stopCommands around the main processCreating runtime directories
Core stanzas of an Upstart job

Administrators could disable or change a packaged job without editing it by creating an override file, for example /etc/init/ssh.override containing manual. Jobs could also be instance jobs, where one definition runs several copies distinguished by a variable such as a terminal name.

Controlling services with initctl

Upstart is controlled through initctl, which talks to PID 1 over a D-Bus style socket. The shorter commands start, stop, restart and status are symbolic links to it. Typical calls include initctl list to show all jobs and their states, status ssh to check one service and initctl emit my-event to send a custom event that other jobs can wait for.

For compatibility, Ubuntu kept the service wrapper and SysV scripts in /etc/init.d. A special rc job ran those scripts when Upstart emitted runlevel events, so older packages kept working during the transition. Later Ubuntu releases also added session jobs, which let Upstart supervise per-user processes in a desktop session.

Upstart compared with other init systems

Upstart differs from its neighbors mainly in how it decides what to start. SysVinit follows a fixed sequence, Upstart follows events forward, and systemd works backward from a requested target through declared dependencies.

Init systemStart modelSupervisionStatus today
SysVinitOrdered scripts per runlevelNone built inNiche, kept by some distributions
UpstartEvent-driven job triggersRespawn with limitsUnmaintained since 2014
systemdDependency graph and targetsFull supervision with cgroupsDefault on most distributions
OpenRCDependency-based scriptsOptional supervisorUsed by Gentoo and Alpine
runitSimple service directoriesBuilt inUsed by Void Linux
Upstart compared with related init systems

A known weakness of the event model is that it describes triggers, not requirements. If a job should start when a service is available but that service started earlier, the event has already passed, and the job may never start. systemd replaced this with explicit dependencies, socket activation and cgroup tracking, which is why Ubuntu switched to it in 2015.

Limitations and migration to systemd

Several practical problems explain why Upstart lost its place. Process tracking relied on ptrace-based fork counting through the expect stanza, and a wrong expect value could make Upstart follow the wrong PID or hang the job. It also lacked cgroup containment, so daemons that escaped their parent were hard to stop cleanly.

Migrating a job to systemd usually maps each stanza to a unit file directive. The table summarizes the most common translations.

Upstart stanzasystemd equivalentNote
execExecStart=Prefer a foreground process
respawnRestart=on-failureAdd RestartSec= for delays
start on started XAfter=X with Wants=XDependency instead of event
expect forkType=forkingBetter replaced by Type=simple
env VAR=valueEnvironment=VAR=valueOr an EnvironmentFile=
pre-startExecStartPre=Runs before the main process
Translating Upstart stanzas to systemd units

A plain-language summary

When a Linux computer starts, one special program wakes up all the other services. Upstart was one such program, and it worked like a building manager who reacts to news: when the lights come on, start the elevators; when the doors unlock, open the reception desk.

This made startup faster and flexible, because tasks ran as soon as they were ready. Its weak spot was that if a piece of news was missed, the matching task might never begin. That is one reason most Linux systems later moved to systemd.

An example from practice

An operations engineer maintains an internal reporting service that still runs on an Ubuntu 14.04 virtual machine. The service is defined in /etc/init/reports.conf with start on (filesystem and net-device-up IFACE=eth0), respawn, respawn limit 10 5 and expect fork. After an application update, status reports shows the job as running while the actual daemon has already exited.

The engineer finds that the new release no longer forks, so expect fork makes Upstart track a PID that does not exist. Removing the stanza fixes the immediate fault. During the planned move to Ubuntu 22.04, the job is rewritten as a systemd unit with Type=simple, After=network-online.target and Restart=on-failure, and the service now restarts reliably after crashes.