File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,22 +35,19 @@ if (count($rest) < 1) {
3535
3636$ configSourceClass = $ rest [0 ];
3737
38- $ interval = array_key_exists ('interval ' , $ options ) ? intval ($ options ['interval ' ])
39- : (array_key_exists ('i ' , $ options ) ? intval ($ options ['i ' ])
40- : 0 );
41-
4238probeForAutoloader ($ progname );
4339
4440if (!class_exists ($ configSourceClass )) {
4541 fwrite (STDERR , "Cannot find class: $ configSourceClass " . PHP_EOL );
4642 exit (EXIT_CONFIG_SOURCE_CLASS_NOT_FOUND );
4743}
4844
45+ use PHPLRPM \ConfigurationProcess ;
4946use PHPLRPM \ProcessManager ;
5047
51- $ processManager = $ interval > 0
52- ? new ProcessManager ( $ configSourceClass , $ interval )
53- : new ProcessManager ($ configSourceClass );
48+ $ interval = intval ( $ options [ ' interval ' ] ?? $ options [ ' i ' ] ?? ConfigurationProcess:: DEFAULT_CONFIG_POLL_INTERVAL );
49+
50+ $ processManager = new ProcessManager ($ configSourceClass, $ interval );
5451$ processManager ->run ();
5552
5653function probeForAutoloader ($ programName ): void
Original file line number Diff line number Diff line change 1010
1111class ConfigurationProcess
1212{
13- public const SOCKET_FILE_NAME = ' config ' ;
13+ public const DEFAULT_CONFIG_POLL_INTERVAL = 30 ;
1414
1515 private const CONFIG_POLL_TIME_INIT = 0 ;
1616
@@ -24,7 +24,7 @@ class ConfigurationProcess
2424 public function findConfigSocket ()
2525 {
2626 $ this ->configSocket = FileSystemUtils::findWritableFilePath (
27- self :: SOCKET_FILE_NAME ,
27+ MessageService:: CONFIG_SOCKET_FILE_NAME ,
2828 IPCUtilities::getSocketDirs ()
2929 );
3030 if (is_null ($ this ->configSocket )) {
@@ -67,7 +67,9 @@ public function runConfigurationProcessLoop($supervisorPid)
6767 fwrite (STDERR , '--> Could not send config to supervisor: ' . $ e ->getMessage () . PHP_EOL );
6868 }
6969 }
70- sleep ($ this ->configPollIntervalSeconds );
70+ if ($ this ->configPollIntervalSeconds > 0 ) {
71+ sleep ($ this ->configPollIntervalSeconds );
72+ }
7173 pcntl_signal_dispatch ();
7274 }
7375 }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class ProcessManager
2626 private $ controlMessageHandler ;
2727 private $ messageService ;
2828
29- public function __construct (string $ configurationSourceClass , int $ configPollIntervalSeconds = 30 )
29+ public function __construct (string $ configurationSourceClass , int $ configPollIntervalSeconds = ConfigurationProcess:: DEFAULT_CONFIG_POLL_INTERVAL )
3030 {
3131 fwrite (STDERR , '==> lrpm starting ' . PHP_EOL );
3232 $ this ->configPollIntervalSeconds = $ configPollIntervalSeconds ;
You can’t perform that action at this time.
0 commit comments