]> git.saurik.com Git - apple/launchd.git/blob - launchd/doc/StartupItem-NOTES.rtf
launchd-106.tar.gz
[apple/launchd.git] / launchd / doc / StartupItem-NOTES.rtf
1 {\rtf1\mac\ansicpg10000\cocoartf100
2 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fmodern\fcharset77 Courier;
3 \f3\fswiss\fcharset77 Helvetica-Oblique;}
4 {\colortbl;\red255\green255\blue255;}
5 \vieww12840\viewh12820\viewkind0
6 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
7
8 \f0\b\fs24 \cf0 Logistics of Startup Items:\
9 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
10
11 \f1\b0 \cf0 \
12 Startup items are directory bundles which contain, at a minimum, an executable file and a property list text file. For a startup item named "Foo", the bundle will be a directory named "Foo" containing (at a minimum) an executable "Foo" and a plist file "StartupParameters.plist".\
13 \
14 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
15
16 \f0\b \cf0 Search Paths for Startup Items:\
17 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
18
19 \f1\b0 \cf0 \
20 Startup items may be placed in the "Library" subdirectory of the primary file domains ("System", "Local", and "Network"). The search order is defined by routines defined in NSSystemDirectories.h: Local, then Network, then System. However, because the Network mounts have not been established at the beginning of system startup, bundles in /Network is currently not searched; this may be fixed later such that /Network is searched when ti becomes available. This search order does not define the startup order, but it does effect the handling of conflicts between bundles which provide the same services.\
21 \
22 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
23
24 \f0\b \cf0 Startup Actions:\
25 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
26
27 \f1\b0 \cf0 \
28 Presently, SystemStarter looks for an executable file with the name of the bundle (eg. Foo/Foo), and runs that file with a single argument.\
29 \
30 \'a5 A "start" argument indicates that the service(s) provided by the item are expected to start if they are configured to run. The program may opt to do nothing if the service is not configured to run.\
31 \
32 \'a5 A "stop" argument indicates that the service(s) provided by the item are expected to stop if it is running, regardless of whether it is configured to run.\
33 \
34 \'a5 A "restart" argument indicates that the service(s) provided by the item are expected to one of two things:\
35 \'a5 Stop if the service is running, then start if the service is configured to run. (Same as stop followed by start.)\
36 \'a5 If the service is running and not configured to run, stop the service; if the service is not running and configured to run, start the service; if the service is running and it is configured to run, reconfigure the service (eg. send the server a HUP signal).\
37 \
38 \13 Startup items should take no action if they receive an unknown request and should therefore take care not to ignore the argument altogether; for example, a "stop" argument should most certainly not cause the item to start a service.\
39 \
40 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
41
42 \f0\b \cf0 Item Launch Ordering:\
43 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
44
45 \f1\b0 \cf0 \
46 The plist file contains parameters which tell SystemStarter some information about the executable, such as what services is provides, which services are prerequisites to its use, and so on. The plist contains the following attributes:\
47 \
48 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
49
50 \f2 \cf0 \{\
51 Description = "blah blah";\
52 Provides = ("service", ...);\
53 Requires = ("service", ...);\
54 Uses = ("service", ...);\
55 OrderPreference = "time";\
56 Messages =\
57 \{\
58 start = "Starting blah.";\
59 stop = "Stopping blah.";\
60 \}\
61 \}\
62 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
63
64 \f1 \cf0 \
65 Note that while the above example is writing in the old NeXT-style property list format for compactness, the new XML property lists are also handled. You may prefer using PropertyListEditor.app to editing the property list files manually.\
66 \
67 Provides is an array that declares the services are provided by this bundle. A typical bundle provides a single service. Two bundles may not provide the same service; should multiple bundles which provide the same service be installed on a system, the first one encountered will be run, while the others will be disabled. It is therefore undesireable to provide multiple services in a single bundle unless they are co-dependent, as the overriding of one will effectively override all services in a given bundle (see also "Search Paths for Startup Items").\
68 \
69 Requires and Uses comprise the primary method for sorting bundles into the startup order. Requires is an array of services, provided by other bundles, that must be successfully started before the bundle can be run. If no such service is provided by any other bundle, the requiring bundle will not run. Uses is similar to Requires in that the bundle will attempt wait for the listed services before running, but it will still launch even if no such service can be provided by another bundle.\
70 \
71 OrderPreference provides a hint as to the ordering used when a set of bundles are all ready to load. Bundles which have their prerequisites met (that is, all Requires services are launched and all Uses services are either launched or deemed unavailable) are prioritized in this order, based on OrderPreference:\
72 \
73 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
74
75 \f2 \cf0 First\
76 Early\
77 None (default)\
78 Late\
79 Last\
80 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
81
82 \f1 \cf0 \
83 Note that
84 \f3\i other than the above ordering rules, there are no guarantees about the startup order of items
85 \f1\i0 . That is, if multiple items are prioritized equally given the above constraints, there is no rule for which starts first. You must use the dependency mechanism to ensure the correct dependencies have been met. Note also that OrderPreference is merely a suggestion, and that SystemStarter may opt to disregard it. In particular, startup items are run parallel, and items which have dependencies met will be run without waiting for items of a lower OrderPreference to complete.\
86 \
87 Description is a general-use string describing the item, for use by Admin tools. The Messages property provides strings which are displayed by SystemStarter during startup and shutdown.\
88 \
89 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
90
91 \f0\b \cf0 Shutdown:\
92 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
93
94 \f1\b0 \cf0 \
95 The intent is to add a shutdown sequence in the future so that the computer can be brought down more cleanly and give services a change to store state before exiting. The mechanism for this is still in the design stage.\
96 }