init: support custom actions

Bug #94873 reported by Alex Smith
50
This bug affects 8 people
Affects Status Importance Assigned to Milestone
upstart
Triaged
Wishlist
Unassigned

Bug Description

Initctl should have a reload command which allows you to send a signal to a process, SIGHUP by default, although it should allow you to specify a different signal such as SIGUSR1. This would be the equivalent of having a reload command in a sysvinit script. It is useful for if you need to send SIGHUP to a process without using hacks to find the pid.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

The way in which I've been thinking of doing this is to permit the job to define custom actions (in addition to those built-in during the usual job cycle).

These actions would be permitted to be run while the job is running, and would receive the current pid as an environment variable, etc.

If you look at the upstart code, you'll see that most of the support is already there for this and it just needs completing.

In particular, the syntax for specifying them in the configuration file.

Changed in upstart:
importance: Undecided → Wishlist
status: Unconfirmed → Confirmed
Changed in upstart:
status: Confirmed → Triaged
Changed in upstart:
status: Triaged → Fix Committed
status: Fix Committed → Confirmed
Changed in upstart:
milestone: 0.5 → none
Changed in upstart:
milestone: none → 0.10
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Custom actions should be able to be binaries of scripts (exec/script) as with other job processes, and also should be able to be signals to send to the running process.

We'll want to define whether the action can only run while the job is running, or whether it's a detacted action that can run anytime.

summary: - Initctl should have a reload command
+ init: support custom actions
Changed in upstart:
milestone: 0.10 → none
status: Confirmed → Triaged
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

The last time I wrote down the syntax for this, it looked like:

  action reload
    signal HUP
  end action

  action graceful
    exec /usr/sbin/apache2 -k graceful
  end action

  action rotate-logs
    daily
    exec ...
  end action

  action remote-sync
    while network-device
    exec ...
  end action

  action backup
    unattached
    daily
    exec ...
  end action

Revision history for this message
Marques Johansson (marques) wrote :

While installing "blueman" from the ppa, I encountered this problem - sort of. /sbin/reload needed to exist.
Following the way "restart", "start", and "stop" were made executable, this was my workaround:
sudo ln -s initctl /sbin/reload

Revision history for this message
Bryan McLellan (btm) wrote :

Bug #433544 added support for reload in upstart >= 0.6.3-4, separately from other 'custom action' functionality.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Although custom actions would allow a great deal of flexibility, this might be somewhat of a "double-edged sword".

After discussions at UDS-P (https://blueprints.launchpad.net/ubuntu/+spec/foundations-p-upstart-for-admins), it was generally agreed that a first step would be to enhance the abilities of the 'reload' and 'restart' commands. Since the current command set covers 99% of all known use-cases so custom actions are being deferred for the time being.

See bug 893021.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.