Differences between revisions 3 and 4
Revision 3 as of 2006-11-24 12:02:52
Size: 1942
Editor: scott
Comment: rename spec
Revision 4 as of 2006-11-29 11:34:35
Size: 1959
Editor: scott
Comment: fix up
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
When in a job, there is currently no way to find out which job you're actually in. This specification proposes adding an environment variable containing the job name. This specification proposes exporting an environment variable to all job processes so that it is possible for scripts and binaries to determine which job they are being run within.
Line 20: Line 20:
 * Allow calling of `stop` directly from a job without having to specify the job name.  * Allow calling of `start` or `stop` directly from a job without having to specify the job name.
Line 24: Line 24:
The scope of this specification is purely limited to the addition and use of this environment variable. The scope of this specification is limited to the addition and use of this environment variable.

Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.

Summary

This specification proposes exporting an environment variable to all job processes so that it is possible for scripts and binaries to determine which job they are being run within.

Rationale

Jobs will frequently use libraries of functions or helper tools that may wish to adjust their behaviour depending on the job being run. In particular, initctl may wish to act on the job it's being called from by default.

Use cases

  • Common function or binary that changes behaviour for a certain job.
  • Allow calling of start or stop directly from a job without having to specify the job name.

Scope

The scope of this specification is limited to the addition and use of this environment variable.

Design

  • The name of the job is placed in the UPSTART_JOB environment variable for any process.

  • initctl commands that accept a job will default to UPSTART_JOB if none is given.

    pre-start script
        [ $DISABLED ] && stop
    end script
    
    post-stop script
        [ $RESPAWN ] && start
    end script

Implementation

Code

The environment variable will be seeded by modifying process_setup_environment in init/process.c.

start_action in util/initctl.c will be modified to check this variable when no arguments are given, and only error if the variable is also missing.

Data preservation and migration

These changes are backwards compatible with the previous behaviour.


CategorySpec

JobEnvironmentVariable (last edited 2006-11-29 11:34:35 by scott)