@@ -4,6 +4,7 @@ abstract class PhabricatorAphlictManagementWorkflow
4
4
extends PhabricatorManagementWorkflow {
5
5
6
6
private $ debug = false ;
7
+ private $ configData ;
7
8
private $ configPath ;
8
9
9
10
final protected function setDebug ($ debug ) {
@@ -74,6 +75,8 @@ protected function parseLaunchArguments(PhutilArgumentParser $args) {
74
75
$ data ,
75
76
array (
76
77
'servers ' => 'list<wild> ' ,
78
+ 'logs ' => 'optional list<wild> ' ,
79
+ 'pidfile ' => 'string ' ,
77
80
));
78
81
} catch (Exception $ ex ) {
79
82
throw new PhutilArgumentUsageException (
@@ -174,43 +177,54 @@ protected function parseLaunchArguments(PhutilArgumentParser $args) {
174
177
'admin ' ));
175
178
}
176
179
177
- $ this ->configPath = $ full_path ;
178
- }
180
+ $ logs = $ data ['logs ' ];
181
+ foreach ($ logs as $ index => $ log ) {
182
+ PhutilTypeSpec::checkMap (
183
+ $ log ,
184
+ array (
185
+ 'path ' => 'string ' ,
186
+ ));
179
187
180
- final public function getPIDPath () {
181
- $ path = PhabricatorEnv::getEnvConfig ('notification.pidfile ' );
188
+ $ path = $ log ['path ' ];
182
189
183
- try {
184
- $ dir = dirname ($ path );
185
- if (!Filesystem::pathExists ($ dir )) {
186
- Filesystem::createDirectory ($ dir , 0755 , true );
190
+ try {
191
+ $ dir = dirname ($ path );
192
+ if (!Filesystem::pathExists ($ dir )) {
193
+ Filesystem::createDirectory ($ dir , 0755 , true );
194
+ }
195
+ } catch (FilesystemException $ ex ) {
196
+ throw new PhutilArgumentUsageException (
197
+ pht (
198
+ 'Failed to create directory "%s" for specified log file (with ' .
199
+ 'index "%s"). You should manually create this directory or ' .
200
+ 'choose a different logfile location. %s ' ,
201
+ $ dir ,
202
+ $ ex ->getMessage ()));
187
203
}
188
- } catch (FilesystemException $ ex ) {
189
- throw new Exception (
190
- pht (
191
- "Failed to create '%s'. You should manually create this directory. " ,
192
- $ dir ));
193
204
}
194
205
195
- return $ path ;
196
- }
197
-
198
- final public function getLogPath () {
199
- $ path = PhabricatorEnv::getEnvConfig ('notification.log ' );
206
+ $ this ->configData = $ data ;
207
+ $ this ->configPath = $ full_path ;
200
208
209
+ $ pid_path = $ this ->getPIDPath ();
201
210
try {
202
211
$ dir = dirname ($ path );
203
212
if (!Filesystem::pathExists ($ dir )) {
204
213
Filesystem::createDirectory ($ dir , 0755 , true );
205
214
}
206
215
} catch (FilesystemException $ ex ) {
207
- throw new Exception (
216
+ throw new PhutilArgumentUsageException (
208
217
pht (
209
- "Failed to create '%s'. You should manually create this directory. " ,
210
- $ dir ));
218
+ 'Failed to create directory "%s" for specified PID file. You ' .
219
+ 'should manually create this directory or choose a different ' .
220
+ 'PID file location. %s ' ,
221
+ $ dir ,
222
+ $ ex ->getMessage ()));
211
223
}
224
+ }
212
225
213
- return $ path ;
226
+ final public function getPIDPath () {
227
+ return $ this ->configData ['pidfile ' ];
214
228
}
215
229
216
230
final public function getPID () {
@@ -293,12 +307,8 @@ final protected function willLaunch() {
293
307
}
294
308
295
309
private function getServerArgv () {
296
- $ log = $ this ->getLogPath ();
297
-
298
310
$ server_argv = array ();
299
311
$ server_argv [] = '--config= ' .$ this ->configPath ;
300
- $ server_argv [] = '--log= ' .$ log ;
301
-
302
312
return $ server_argv ;
303
313
}
304
314
0 commit comments