@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$autoload = __DIR__ . "/../vendor/autoload.php"; |
|
3 | +$autoload = __DIR__."/../vendor/autoload.php"; |
|
4 | 4 | if (!file_exists($autoload)) { |
5 | - $autoload = __DIR__ . "/../../../../autoload.php"; |
|
5 | + $autoload = __DIR__."/../../../../autoload.php"; |
|
6 | 6 | if (!file_exists($autoload)) { |
7 | 7 | throw new \Exception('Autoload not found. Did you run `composer dump-autload`?'); |
8 | 8 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | { |
12 | 12 | public function process() |
13 | 13 | { |
14 | - file_put_contents(sys_get_temp_dir() . '/tryme.txt', date('c') . "\n", FILE_APPEND); |
|
15 | - file_put_contents(sys_get_temp_dir() . '/tryme.txt', print_r($_REQUEST, true), FILE_APPEND); |
|
14 | + file_put_contents(sys_get_temp_dir().'/tryme.txt', date('c')."\n", FILE_APPEND); |
|
15 | + file_put_contents(sys_get_temp_dir().'/tryme.txt', print_r($_REQUEST, true), FILE_APPEND); |
|
16 | 16 | } |
17 | 17 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | } else { |
27 | 27 | $output->writeln("List of daemonize services: "); |
28 | 28 | foreach ($list as $filename) { |
29 | - $output->writeln(" - " . basename($filename)); |
|
29 | + $output->writeln(" - ".basename($filename)); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | $output->writeln(""); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | $this->instance = new $className(); |
45 | 45 | } catch (Exception $ex) { |
46 | 46 | $this->writeToStderr("System Fail to Start: \n"); |
47 | - $this->writeToStderr('Message: ' . $ex->getMessage() . "\n"); |
|
48 | - $this->writeToStderr("Stack Trace:\n" . $ex->getTraceAsString()); |
|
47 | + $this->writeToStderr('Message: '.$ex->getMessage()."\n"); |
|
48 | + $this->writeToStderr("Stack Trace:\n".$ex->getTraceAsString()); |
|
49 | 49 | $this->writeToStderr("\n\n"); |
50 | 50 | } |
51 | 51 | } |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | if (empty($logname)) { |
60 | - $logname = str_replace("\\", "_", strtolower($this->className)) . "." . strtolower($this->methodName); |
|
60 | + $logname = str_replace("\\", "_", strtolower($this->className)).".".strtolower($this->methodName); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if ( |
64 | - is_writable(self::BASE_LOG_PATH . '/' . $logname . '.log') |
|
65 | - && is_writable(self::BASE_LOG_PATH . '/' . $logname . '.error.log') |
|
64 | + is_writable(self::BASE_LOG_PATH.'/'.$logname.'.log') |
|
65 | + && is_writable(self::BASE_LOG_PATH.'/'.$logname.'.error.log') |
|
66 | 66 | ) { |
67 | 67 | fclose(STDIN); |
68 | 68 | fclose(STDOUT); |
69 | 69 | fclose(STDERR); |
70 | 70 | $this->stdIn = fopen('/dev/null', 'r'); |
71 | - $this->stdOut = fopen(self::BASE_LOG_PATH . '/' . $logname . '.log', 'ab'); |
|
72 | - $this->stdErr = fopen(self::BASE_LOG_PATH . '/' . $logname . '.error.log', 'ab'); |
|
71 | + $this->stdOut = fopen(self::BASE_LOG_PATH.'/'.$logname.'.log', 'ab'); |
|
72 | + $this->stdErr = fopen(self::BASE_LOG_PATH.'/'.$logname.'.error.log', 'ab'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $instance = $this->instance; |
92 | 92 | $method = $this->methodName; |
93 | 93 | |
94 | - $this->writeToStdout("Service " . $this->className . "::" . $this->methodName . " started at " . date('c') . "\n"); |
|
94 | + $this->writeToStdout("Service ".$this->className."::".$this->methodName." started at ".date('c')."\n"); |
|
95 | 95 | |
96 | 96 | $continue = true; |
97 | 97 | |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | $this->writeToStdout($output); |
104 | 104 | } |
105 | 105 | } catch (Exception $ex) { |
106 | - $this->writeToStderr(date('c') . ' [' . get_class($ex) . '] in ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' -- ' . "\n"); |
|
107 | - $this->writeToStderr('Message: ' . $ex->getMessage() . "\n"); |
|
108 | - $this->writeToStderr("Stack Trace:\n" . $ex->getTraceAsString()); |
|
106 | + $this->writeToStderr(date('c').' ['.get_class($ex).'] in '.$ex->getFile().' at line '.$ex->getLine().' -- '."\n"); |
|
107 | + $this->writeToStderr('Message: '.$ex->getMessage()."\n"); |
|
108 | + $this->writeToStderr("Stack Trace:\n".$ex->getTraceAsString()); |
|
109 | 109 | $this->writeToStderr("\n\n"); |
110 | 110 | } |
111 | 111 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | 'rootdir', |
31 | 31 | InputArgument::OPTIONAL, |
32 | 32 | 'The root path where your application is installed', |
33 | - getcwd() . "/" |
|
33 | + getcwd()."/" |
|
34 | 34 | ) |
35 | 35 | ->addArgument( |
36 | 36 | 'args', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $bootstrap = $input->getArgument('bootstrap'); |
46 | 46 | $rootPath = $input->getArgument('rootdir'); |
47 | 47 | |
48 | - $realPathBootstrap = realpath($rootPath . $bootstrap); |
|
48 | + $realPathBootstrap = realpath($rootPath.$bootstrap); |
|
49 | 49 | $realPathRootPath = realpath($rootPath); |
50 | 50 | |
51 | 51 | if (!file_exists($realPathRootPath)) { |
@@ -43,7 +43,7 @@ |
||
43 | 43 | 'rootdir', |
44 | 44 | InputArgument::OPTIONAL, |
45 | 45 | 'The root path where your application is installed', |
46 | - getcwd() . "/" |
|
46 | + getcwd()."/" |
|
47 | 47 | ) |
48 | 48 | ->addArgument( |
49 | 49 | 'description', |
@@ -99,6 +99,9 @@ |
||
99 | 99 | return true; |
100 | 100 | } |
101 | 101 | |
102 | + /** |
|
103 | + * @param string $text |
|
104 | + */ |
|
102 | 105 | protected static function replaceVars($vars, $text) |
103 | 106 | { |
104 | 107 | foreach ($vars as $searchFor=>$replace) { |
@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | } |
29 | 29 | $targetServicePath = $targetPathAvailable[$template]; |
30 | 30 | |
31 | - $templatePath = __DIR__ . "/../template/linux-" . $template . "-service.tpl"; |
|
31 | + $templatePath = __DIR__."/../template/linux-".$template."-service.tpl"; |
|
32 | 32 | |
33 | 33 | if (!file_exists($templatePath)) { |
34 | 34 | throw new \Exception("Template '$templatePath' not found"); |
35 | 35 | } |
36 | 36 | |
37 | - $bootstrap = $curdir . '/' . $bootstrap; |
|
37 | + $bootstrap = $curdir.'/'.$bootstrap; |
|
38 | 38 | if (!file_exists($bootstrap) && $check) { |
39 | 39 | throw new \Exception("Bootstrap '$bootstrap' not found"); |
40 | 40 | } |
41 | 41 | |
42 | - $autoload = realpath(__DIR__ . "/../vendor/autoload.php"); |
|
42 | + $autoload = realpath(__DIR__."/../vendor/autoload.php"); |
|
43 | 43 | if (!file_exists($autoload)) { |
44 | - $autoload = realpath(__DIR__ . "/../../../autoload.php"); |
|
44 | + $autoload = realpath(__DIR__."/../../../autoload.php"); |
|
45 | 45 | if (!file_exists($autoload) && $check) { |
46 | 46 | throw new \Exception('Daemonize autoload not found. Did you run `composer dump-autload`?'); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | 50 | if (!empty($consoleArgs)) { |
51 | - for ($i=0; $i<count($consoleArgs); $i++) { |
|
51 | + for ($i = 0; $i < count($consoleArgs); $i++) { |
|
52 | 52 | $consoleArgs[$i] = str_replace('"', '\\"', $consoleArgs[$i]); |
53 | 53 | } |
54 | - $consoleArgsPrepared = '[ "' . implode('", "', $consoleArgs) . '" ]'; |
|
54 | + $consoleArgsPrepared = '[ "'.implode('", "', $consoleArgs).'" ]'; |
|
55 | 55 | } else { |
56 | 56 | $consoleArgsPrepared = "[ ]"; |
57 | 57 | } |
58 | 58 | |
59 | - $serviceTemplatePath = __DIR__ . "/../template/_service.php.tpl"; |
|
60 | - $daemonizeService = __DIR__ . "/../services/$svcName.php"; |
|
59 | + $serviceTemplatePath = __DIR__."/../template/_service.php.tpl"; |
|
60 | + $daemonizeService = __DIR__."/../services/$svcName.php"; |
|
61 | 61 | $phpPath = PHP_BINARY; |
62 | 62 | |
63 | 63 | $vars = [ |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | require_once($vars['#BOOTSTRAP#']); |
83 | 83 | $classParts = explode('::', str_replace("\\\\", "\\", $vars['#CLASS#'])); |
84 | 84 | if (!class_exists($classParts[0])) { |
85 | - throw new \Exception('Could not find class ' . $classParts[0]); |
|
85 | + throw new \Exception('Could not find class '.$classParts[0]); |
|
86 | 86 | } |
87 | 87 | $className = $classParts[0]; |
88 | 88 | $classTest = new $className(); |
89 | 89 | if (!method_exists($classTest, $classParts[1])) { |
90 | - throw new \Exception('Could not find method ' . $vars['#CLASS#']); |
|
90 | + throw new \Exception('Could not find method '.$vars['#CLASS#']); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - set_error_handler(function ($number, $error) { |
|
94 | + set_error_handler(function($number, $error) { |
|
95 | 95 | throw new \Exception($error); |
96 | 96 | }); |
97 | 97 | file_put_contents($targetServicePath, $templateStr); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | protected static function isDaemonizeService($filename) |
140 | 140 | { |
141 | - set_error_handler(function ($number, $error) { |
|
141 | + set_error_handler(function($number, $error) { |
|
142 | 142 | throw new \Exception($error); |
143 | 143 | }); |
144 | 144 |