@@ -185,6 +185,9 @@ |
||
185 | 185 | |
186 | 186 | } |
187 | 187 | |
188 | + /** |
|
189 | + * @param integer $looptime |
|
190 | + */ |
|
188 | 191 | public static function getLoopTime($looptime) { |
189 | 192 | |
190 | 193 | return filter_var($looptime, FILTER_VALIDATE_INT, array( |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | |
110 | 110 | $this->logger->notice("Starting daemon (looping each ".$this->looptime." secs, pid: ".$this->pid.")"); |
111 | 111 | |
112 | - $this->events->emit( new DaemonEvent('start', $this) ); |
|
112 | + $this->events->emit(new DaemonEvent('start', $this)); |
|
113 | 113 | |
114 | - while ($this->loopactive) { |
|
114 | + while ( $this->loopactive ) { |
|
115 | 115 | |
116 | 116 | $start = microtime(true); |
117 | 117 | |
118 | 118 | pcntl_signal_dispatch(); |
119 | 119 | |
120 | - $this->events->emit( new DaemonEvent('preloop', $this) ); |
|
120 | + $this->events->emit(new DaemonEvent('preloop', $this)); |
|
121 | 121 | |
122 | - if ( $this->runlock->check() && $this->loopactive) { |
|
122 | + if ( $this->runlock->check() && $this->loopactive ) { |
|
123 | 123 | |
124 | - $this->events->emit( new DaemonEvent('loopstart', $this) ); |
|
124 | + $this->events->emit(new DaemonEvent('loopstart', $this)); |
|
125 | 125 | |
126 | 126 | $this->loop(); |
127 | 127 | |
128 | - $this->events->emit( new DaemonEvent('loopstop', $this) ); |
|
128 | + $this->events->emit(new DaemonEvent('loopstop', $this)); |
|
129 | 129 | |
130 | 130 | $this->loopcount++; |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - $this->events->emit( new DaemonEvent('postloop', $this) ); |
|
134 | + $this->events->emit(new DaemonEvent('postloop', $this)); |
|
135 | 135 | |
136 | 136 | $this->loopelapsed = (microtime(true) - $start); |
137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $this->logger->notice("Stopping daemon (pid: ".$this->pid.")"); |
145 | 145 | |
146 | - $this->events->emit( new DaemonEvent('stop', $this) ); |
|
146 | + $this->events->emit(new DaemonEvent('stop', $this)); |
|
147 | 147 | |
148 | 148 | $this->end(0); |
149 | 149 |
@@ -45,8 +45,7 @@ |
||
45 | 45 | LoggerInterface $logger, |
46 | 46 | Emitter $events, |
47 | 47 | $looptime = 1, |
48 | - $niceness = null) |
|
49 | - { |
|
48 | + $niceness = null) { |
|
50 | 49 | |
51 | 50 | parent::__construct($configuration, $logger, $events, $niceness); |
52 | 51 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | ) { |
28 | 28 | |
29 | 29 | // parsing configuration |
30 | - $this->configuration = new Configuration( DefaultConfiguration::get() ); |
|
30 | + $this->configuration = new Configuration(DefaultConfiguration::get()); |
|
31 | 31 | $this->configuration->merge($configuration); |
32 | 32 | |
33 | 33 | // fix the daemon start time |
@@ -14,24 +14,24 @@ |
||
14 | 14 | $chars = 60; |
15 | 15 | |
16 | 16 | // show the header |
17 | - $console->br()->border('-',$chars); |
|
17 | + $console->br()->border('-', $chars); |
|
18 | 18 | $console->bold()->flank('Extender execution summary'); |
19 | - $console->border('-',$chars); |
|
19 | + $console->border('-', $chars); |
|
20 | 20 | $console->out('Total run time: '.self::calculateRunTime($daemon->starttime)); |
21 | - $console->border('-',$chars); |
|
21 | + $console->border('-', $chars); |
|
22 | 22 | $padding = $console->padding(26); |
23 | - $padding->label('Total processed jobs')->result($daemon->completedjobs+$daemon->failedjobs); |
|
23 | + $padding->label('Total processed jobs')->result($daemon->completedjobs + $daemon->failedjobs); |
|
24 | 24 | $padding = $console->padding(30); |
25 | 25 | $padding->label('├─ Completed')->result('<light_green>'.$daemon->completedjobs.'</green>'); |
26 | 26 | $padding->label('└─ Failed')->result('<red>'.$daemon->failedjobs.'</red>'); |
27 | - $console->border('-',$chars); |
|
27 | + $console->border('-', $chars); |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | |
31 | 31 | private static function calculateRunTime($starttime) { |
32 | 32 | |
33 | - $start_formatted = sprintf("%06d",($starttime - floor($starttime)) * 1000000); |
|
34 | - $start = new DateTime( date('Y-m-d H:i:s.'.$start_formatted, $starttime) ); |
|
33 | + $start_formatted = sprintf("%06d", ($starttime - floor($starttime)) * 1000000); |
|
34 | + $start = new DateTime(date('Y-m-d H:i:s.'.$start_formatted, $starttime)); |
|
35 | 35 | $end = new DateTime(); |
36 | 36 | |
37 | 37 | $diff = $end->diff($start); |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | $daemon = $event->getDaemon(); |
11 | 11 | |
12 | - if ( $daemon->looplimit === $daemon->loopcount) { |
|
12 | + if ( $daemon->looplimit === $daemon->loopcount ) { |
|
13 | 13 | $daemon->logger->info('Stopping daemon due to loop limit ('.$daemon->looplimit.') reached'); |
14 | 14 | // $daemon->stop(); |
15 | 15 | $daemon->loopactive = false; |
@@ -14,10 +14,10 @@ |
||
14 | 14 | |
15 | 15 | if ( empty($jobs) ) return; |
16 | 16 | |
17 | - $console->border('-',30); |
|
17 | + $console->border('-', 30); |
|
18 | 18 | $console->bold()->green('Extender loop summary'); |
19 | 19 | $console->out("Loop duration: ".round($daemon->loopelapsed)); |
20 | - $console->border('-',30); |
|
20 | + $console->border('-', 30); |
|
21 | 21 | $console->out("Executed jobs: "); |
22 | 22 | $console->table($jobs); |
23 | 23 |