Merge lp:~jamesodhunt/upstart/file-bridge-change-fpath-to-file-et-al into lp:upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1454
Proposed branch: lp:~jamesodhunt/upstart/file-bridge-change-fpath-to-file-et-al
Merge into: lp:upstart
Diff against target: 240 lines (+39/-39)
3 files modified
extra/man/file-event.7 (+17/-17)
extra/man/upstart-file-bridge.8 (+15/-15)
extra/upstart-file-bridge.c (+7/-7)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/file-bridge-change-fpath-to-file-et-al
Reviewer Review Type Date Requested Status
Upstart Reviewers Pending
Review via email: mp+153603@code.launchpad.net

Description of the change

Make file event environment variables cleaner:

    FPATH => FILE
    FEVENT => EVENT
    FMATCH => MATCH

Note that we cannot change FPATH to PATH since that will already be set
for a Session Job. And using FILE is consistent with runlevel(8)'s
approach.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extra/man/file-event.7'
2--- extra/man/file-event.7 2013-03-15 12:44:29 +0000
3+++ extra/man/file-event.7 2013-03-15 17:17:24 +0000
4@@ -5,9 +5,9 @@
5 .\"
6 .SH SYNOPSIS
7 .B file
8-.BI FPATH\fR= PATH
9-.BI FEVENT\fR= TYPE
10-.IB \fR[ FMATCH\fR= PATH \fR]
11+.BI FILE\fR= PATH
12+.BI EVENT\fR= TYPE
13+.IB \fR[ MATCH\fR= PATH \fR]
14 .\"
15 .SH DESCRIPTION
16
17@@ -23,10 +23,10 @@
18 stanza is modified.
19
20 The
21-.BR FPATH " and " FEVENT
22+.BR FILE " and " EVENT
23 environment variables will be set to the same values as specified by the
24 job. Note that if the job did not specify
25-.B FEVENT
26+.B EVENT
27 this will still be set to one of
28 .BR create ", "
29 .BR modify " or "
30@@ -34,16 +34,16 @@
31 depending on what type of file event caused the event to be emitted.
32
33 The
34-.B FEVENT
35+.B EVENT
36 environment variable will be set to the value of the corresponding
37
38 If the job specified a glob pattern in the file part of the
39-.B FPATH
40+.B FILE
41 environment variable, the event will contain the
42-.B FMATCH
43+.B MATCH
44 environment variable which will be set to the full path of the file that
45 matched the pattern in
46-.BR FPATH "."
47+.BR FILE "."
48 .\"
49 .SH NOTES
50
51@@ -52,31 +52,31 @@
52 quoted.
53 .\"
54 .IP \(bu
55-.B FPATH
56+.B FILE
57 values specified by jobs are not canonicalised; they cannot be reliably as
58 they may not exist so cannot be fully resolved.
59 .\"
60 .IP \(bu
61 If you wish to match on
62-.BR FMATCH ", "
63+.BR MATCH ", "
64 ensure that
65-.B FPATH
66+.B FILE
67 does not contain multiple consecutive runs of slashes since otherwise
68 your job will find it difficult to perform such a match.
69 .\"
70 .SH EXAMPLES
71 .\"
72-.IP "start on file FPATH=/run/app.pid FEVENT=created" 0.4i
73+.IP "start on file FILE=/run/app.pid EVENT=created" 0.4i
74 Event emitted when file is created.
75-.IP "start on file FPATH=/run/app.pid"
76+.IP "start on file FILE=/run/app.pid"
77 Event emitted when file is created, modified or deleted.
78-.IP "start on file FPATH=/var/log/"
79+.IP "start on file FILE=/var/log/"
80 Event emitted when files within a directory are created, modified or
81 deleted.
82-.IP "start on file FPATH=/var/crash/*.crash FEVENT=created"
83+.IP "start on file FILE=/var/crash/*.crash EVENT=created"
84 Event emitted when files in a directory matching a glob pattern are
85 created.
86-.IP "start on file FPATH=""/this/path/contains whitespace.txt"""
87+.IP "start on file FILE=""/this/path/contains whitespace.txt"""
88 Specify a file that contains a space character.
89 .\"
90 .SH AUTHOR
91
92=== modified file 'extra/man/upstart-file-bridge.8'
93--- extra/man/upstart-file-bridge.8 2013-03-11 20:02:18 +0000
94+++ extra/man/upstart-file-bridge.8 2013-03-15 17:17:24 +0000
95@@ -61,7 +61,7 @@
96 .\"
97 .SH JOB ENVIRONMENT VARIABLES
98 .TP
99-.B FPATH
100+.B FILE
101 Path to file to watch. When run without
102 .BR \-\-user ","
103 this must be an absolute path. If
104@@ -93,35 +93,35 @@
105 .RE
106 .\"
107 .TP
108-.B FEVENT
109+.B EVENT
110 Event relating to
111-.B FPATH
112+.B FILE
113 that job is interested in. If this variable is specified the value must
114 be set to
115 .BR create ", "
116 .BR modify " or "
117 .B delete
118 depending on what type of file event the job is interested in. If
119-.B FPATH
120+.B FILE
121 is not specified, the bridge will watch for all types and set this
122 variable to the appropriate value when emitting the event.
123 .\"
124 .SH WATCH TYPE BEHAVIOUR
125
126 The bridge emits events depending not only on the value of
127-.BR FEVENT ", "
128+.BR EVENT ", "
129 but also on the entity specified by
130-.BR FPATH ":"
131+.BR FILE ":"
132 .\"
133 .SS File
134
135 An event will be emitted when the named file is created, modified or
136-deleted depending on the value of \fBFEVENT\fR. If
137-.B FEVENT
138+deleted depending on the value of \fBEVENT\fR. If
139+.B EVENT
140 is not specified, react to creation, modification and deletion.
141
142 If the file already exists when the job is registered, and
143-.B FEVENT
144+.B EVENT
145 either specifies
146 .I create
147 or the variable is not specified, the event will be emitted.
148@@ -131,12 +131,12 @@
149 An event will be emitted when the named directory is created, modified
150 (files within it are created, modified or deleted) or deleted depending
151 on the value of
152-\fBFEVENT\fR. If
153-.B FEVENT
154+\fBEVENT\fR. If
155+.B EVENT
156 is not specified, react to creation, modification and deletion.
157
158 If the directory already exists when the job is registered, and
159-.B FEVENT
160+.B EVENT
161 either specifies
162 .I create
163 or the variable is not specified, the event will be emitted.
164@@ -146,12 +146,12 @@
165 One event will be emitted per match when the glob wildcard matches any
166 files in the directory part is created, modified or deleted, depending
167 on the value of
168-\fBFEVENT\fR. If
169-.B FEVENT
170+\fBEVENT\fR. If
171+.B EVENT
172 is not specified, react to creation, modification and deletion.
173
174 If any matches already exist when the job is registered, and
175-.B FEVENT
176+.B EVENT
177 either specifies
178 .I create
179 or the variable is not specified, events will be emitted.
180
181=== modified file 'extra/upstart-file-bridge.c'
182--- extra/upstart-file-bridge.c 2013-03-15 12:44:29 +0000
183+++ extra/upstart-file-bridge.c 2013-03-15 17:17:24 +0000
184@@ -553,7 +553,7 @@
185 }
186
187 if (user) {
188- /* Ensure we are sitting in $HOME so relative FPATH
189+ /* Ensure we are sitting in $HOME so relative FILE
190 * values work as expected.
191 */
192 if (chdir (home_dir) < 0) {
193@@ -744,7 +744,7 @@
194 name_len = val - *env;
195 val++;
196
197- if (! strncmp (*env, "FPATH", name_len)) {
198+ if (! strncmp (*env, "FILE", name_len)) {
199 char dirpart[PATH_MAX];
200 char basepart[PATH_MAX];
201 char *dir;
202@@ -789,7 +789,7 @@
203 strcpy (path, dir);
204 glob_expr = NIH_MUST (nih_strdup (NULL, base));
205 }
206- } else if (! strncmp (*env, "FEVENT", name_len)) {
207+ } else if (! strncmp (*env, "EVENT", name_len)) {
208 if (! strcmp (val, "create")) {
209 events = IN_CREATE;
210 } else if (! strcmp (val, "modify")) {
211@@ -1359,17 +1359,17 @@
212
213 env = NIH_MUST (nih_str_array_new (NULL));
214
215- var = NIH_MUST (nih_sprintf (NULL, "FPATH=%s", path));
216+ var = NIH_MUST (nih_sprintf (NULL, "FILE=%s", path));
217 NIH_MUST (nih_str_array_addp (&env, NULL, &env_len, var));
218
219- var = NIH_MUST (nih_sprintf (NULL, "FEVENT=%s",
220+ var = NIH_MUST (nih_sprintf (NULL, "EVENT=%s",
221 event_type == IN_CREATE ? "create" :
222 event_type == IN_MODIFY ? "modify" :
223 "delete"));
224 NIH_MUST (nih_str_array_addp (&env, NULL, &env_len, var));
225
226 if (match) {
227- var = NIH_MUST (nih_sprintf (NULL, "FMATCH=%s", match));
228+ var = NIH_MUST (nih_sprintf (NULL, "MATCH=%s", match));
229 NIH_MUST (nih_str_array_addp (&env, NULL, &env_len, var));
230 }
231
232@@ -1444,7 +1444,7 @@
233 * path handed to inotify also gets given to the
234 * create/modify/delete handlers which can then lead to
235 * multiple consecutive slashes which could result in
236- * jobs failing to start as they would not expect FMATCH
237+ * jobs failing to start as they would not expect MATCH
238 * to contain such values.
239 *
240 * Note that we do not (cannot) do this if @path is

Subscribers

People subscribed via source and target branches