@@ -134,7 +134,7 @@ |
||
| 134 | 134 | $CpeClientSdk = new SA\CpeClientSdk($key, $secret, $region, $debug); |
| 135 | 135 | } catch (Exception $e) { |
| 136 | 136 | exit($e->getMessage()); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | // Commands mapping |
| 140 | 140 | $commandMap = [ |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | { |
| 110 | 110 | global $help; |
| 111 | 111 | |
| 112 | - echo("Usage: php ". basename(__FILE__) . " -c configFile [-h] [-k <key>] [-s <secret>] [-r <region>]\n"); |
|
| 112 | + echo("Usage: php " . basename(__FILE__) . " -c configFile [-h] [-k <key>] [-s <secret>] [-r <region>]\n"); |
|
| 113 | 113 | echo("-h: Print this help\n"); |
| 114 | 114 | echo("-d: Debug mode\n"); |
| 115 | 115 | echo("-c: configFile\n"); |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | $decodedClient = json_decode($clientInfo); |
| 39 | 39 | |
| 40 | 40 | $CpeClientSdk->start_job($decodedClient, $content); |
| 41 | - } |
|
| 42 | - catch (Exception $e) { |
|
| 41 | + } catch (Exception $e) { |
|
| 43 | 42 | print("[ERROR] " . $e->getMessage() . "\n"); |
| 44 | 43 | } |
| 45 | 44 | } |
@@ -68,42 +67,51 @@ discard block |
||
| 68 | 67 | global $argv; |
| 69 | 68 | |
| 70 | 69 | // Handle input parameters |
| 71 | - if (!($options = getopt("c:k::s::r::hd"))) |
|
| 72 | - usage(); |
|
| 73 | - if (isset($options['h'])) |
|
| 74 | - usage(); |
|
| 70 | + if (!($options = getopt("c:k::s::r::hd"))) { |
|
| 71 | + usage(); |
|
| 72 | + } |
|
| 73 | + if (isset($options['h'])) { |
|
| 74 | + usage(); |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | - if (isset($options['d'])) |
|
| 77 | - $debug = true; |
|
| 77 | + if (isset($options['d'])) { |
|
| 78 | + $debug = true; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | if (isset($options['c'])) |
| 80 | 82 | { |
| 81 | 83 | $clientConfFile = $options['c']; |
| 82 | - if (!file_exists($clientConfFile)) |
|
| 83 | - throw new Exception("The client config file is not valid!"); |
|
| 84 | - if (!($clientInfo = file_get_contents($clientConfFile))) |
|
| 85 | - throw new Exception("Unable to read the file"); |
|
| 86 | - } |
|
| 87 | - else |
|
| 88 | - throw new Exception("Please provide the client config file!"); |
|
| 89 | - |
|
| 90 | - if (isset($options['k'])) |
|
| 91 | - $key = $options['k']; |
|
| 92 | - else |
|
| 93 | - $key = getenv("AWS_ACCESS_KEY_ID"); |
|
| 84 | + if (!file_exists($clientConfFile)) { |
|
| 85 | + throw new Exception("The client config file is not valid!"); |
|
| 86 | + } |
|
| 87 | + if (!($clientInfo = file_get_contents($clientConfFile))) { |
|
| 88 | + throw new Exception("Unable to read the file"); |
|
| 89 | + } |
|
| 90 | + } else { |
|
| 91 | + throw new Exception("Please provide the client config file!"); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (isset($options['k'])) { |
|
| 95 | + $key = $options['k']; |
|
| 96 | + } else { |
|
| 97 | + $key = getenv("AWS_ACCESS_KEY_ID"); |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | - if (isset($options['s'])) |
|
| 96 | - $secret = $options['s']; |
|
| 97 | - else |
|
| 98 | - $secret = getenv("AWS_SECRET_KEY"); |
|
| 99 | - |
|
| 100 | - if (isset($options['r'])) |
|
| 101 | - $region = $options['r']; |
|
| 102 | - else |
|
| 103 | - $region = getenv("AWS_DEFAULT_REGION"); |
|
| 104 | - if (!$region) |
|
| 105 | - throw new Exception("Please provide your AWS region as parameter or using AWS_DEFAULT_REGION env var !"); |
|
| 106 | -} |
|
| 100 | + if (isset($options['s'])) { |
|
| 101 | + $secret = $options['s']; |
|
| 102 | + } else { |
|
| 103 | + $secret = getenv("AWS_SECRET_KEY"); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + if (isset($options['r'])) { |
|
| 107 | + $region = $options['r']; |
|
| 108 | + } else { |
|
| 109 | + $region = getenv("AWS_DEFAULT_REGION"); |
|
| 110 | + } |
|
| 111 | + if (!$region) { |
|
| 112 | + throw new Exception("Please provide your AWS region as parameter or using AWS_DEFAULT_REGION env var !"); |
|
| 113 | + } |
|
| 114 | + } |
|
| 107 | 115 | |
| 108 | 116 | function usage() |
| 109 | 117 | { |
@@ -123,8 +131,7 @@ discard block |
||
| 123 | 131 | |
| 124 | 132 | try { |
| 125 | 133 | check_input_parameters(); |
| 126 | -} |
|
| 127 | -catch (Exception $e) { |
|
| 134 | +} catch (Exception $e) { |
|
| 128 | 135 | print "[ERROR] " . $e->getMessage() . "\n"; |
| 129 | 136 | exit(2); |
| 130 | 137 | } |
@@ -147,14 +154,16 @@ discard block |
||
| 147 | 154 | { |
| 148 | 155 | // Prompt (<3 php) |
| 149 | 156 | $line = readline("Command [enter]: "); |
| 150 | - if (!$line) |
|
| 151 | - continue; |
|
| 157 | + if (!$line) { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 152 | 160 | readline_add_history($line); |
| 153 | 161 | |
| 154 | 162 | // Process user input |
| 155 | 163 | $args = explode(" ", $line); |
| 156 | - if (!isset($commandMap[$args[0]])) |
|
| 157 | - print "[ERROR] Command not found!\n"; |
|
| 158 | - else |
|
| 159 | - $commandMap[$args[0]]($args); |
|
| 160 | -} |
|
| 161 | 164 | \ No newline at end of file |
| 165 | + if (!isset($commandMap[$args[0]])) { |
|
| 166 | + print "[ERROR] Command not found!\n"; |
|
| 167 | + } else { |
|
| 168 | + $commandMap[$args[0]]($args); |
|
| 169 | + } |
|
| 170 | + } |
|
| 162 | 171 | \ No newline at end of file |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | Commands: |
| 56 | 56 | start_job <filepath>: Start a new job. Pass a JSON file containing the instruction (see: input_samples folder) |
| 57 | 57 | |
| 58 | -EOF; |
|
| 58 | +eof; |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | function check_input_parameters() |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | $this->cpeLogger->log_out( |
| 108 | 108 | "ERROR", |
| 109 | 109 | basename(__FILE__), |
| 110 | - $e->getMessage().print_r($msg, true)); |
|
| 110 | + $e->getMessage() . print_r($msg, true)); |
|
| 111 | 111 | } catch (\Exception $e) { |
| 112 | 112 | $this->cpeLogger->log_out( |
| 113 | 113 | "ERROR", |
| 114 | 114 | basename(__FILE__), |
| 115 | - $e->getMessage().print_r($msg, true)); |
|
| 115 | + $e->getMessage() . print_r($msg, true)); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Message polled. Valid or not, we delete it from SQS |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->cpeLogger->log_out( |
| 141 | 141 | "INFO", |
| 142 | 142 | basename(__FILE__), |
| 143 | - "Received message '" . $message->{"type"} . "'" |
|
| 143 | + "Received message '" . $message->{"type"} . "'" |
|
| 144 | 144 | ); |
| 145 | 145 | if ($this->debug) |
| 146 | 146 | $this->cpeLogger->log_out( |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $this->cpeLogger->log_out( |
| 190 | 190 | "INFO", |
| 191 | 191 | basename(__FILE__), |
| 192 | - "New workflow submitted to SWF: ".$workflowRunId->get('runId')); |
|
| 192 | + "New workflow submitted to SWF: " . $workflowRunId->get('runId')); |
|
| 193 | 193 | |
| 194 | 194 | // Send WORKFLOW_SCHEDULED message back to client |
| 195 | 195 | $this->cpeSqsWriter->workflow_scheduled($workflowType, $workflowRunId->get('runId'), $workflowId, $message); |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | private function validate_message($message) |
| 216 | 216 | { |
| 217 | 217 | if (!isset($message) || |
| 218 | - !isset($message->{"time"}) || $message->{"time"} == "" || |
|
| 219 | - !isset($message->{"jobId"}) || $message->{"jobId"} == "" || |
|
| 220 | - !isset($message->{"type"}) || $message->{"type"} == "" || |
|
| 221 | - !isset($message->{"data"}) || $message->{"data"} == "") |
|
| 218 | + !isset($message->{"time"}) || $message->{"time"} == "" || |
|
| 219 | + !isset($message->{"jobId"}) || $message->{"jobId"} == "" || |
|
| 220 | + !isset($message->{"type"}) || $message->{"type"} == "" || |
|
| 221 | + !isset($message->{"data"}) || $message->{"data"} == "") |
|
| 222 | 222 | throw new CpeSdk\CpeException("'time', 'type', 'jobId' or 'data' fields missing in JSON message file!", |
| 223 | 223 | self::INVALID_JSON); |
| 224 | 224 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | function usage($defaultConfigFile) |
| 240 | 240 | { |
| 241 | - echo("Usage: php ". basename(__FILE__) . " [-h] [-d] [-n <client_name>] [-l <log path>] -c <config_file path>\n"); |
|
| 241 | + echo("Usage: php " . basename(__FILE__) . " [-h] [-d] [-n <client_name>] [-l <log path>] -c <config_file path>\n"); |
|
| 242 | 242 | echo("-h: Print this help\n"); |
| 243 | 243 | echo("-d: Debug mode\n"); |
| 244 | 244 | echo("-l <log_path>: Location where logs will be dumped in (folder).\n"); |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | if (isset($options['n'])) |
| 291 | 291 | { |
| 292 | - $config->clients = [(object)[ |
|
| 292 | + $config->clients = [(object) [ |
|
| 293 | 293 | 'name' => $options['n'], |
| 294 | - 'queues' => (object)[ |
|
| 294 | + 'queues' => (object) [ |
|
| 295 | 295 | 'input' => getenv('INPUT_QUEUE'), |
| 296 | 296 | 'output' => getenv('OUTPUT_QUEUE'), |
| 297 | 297 | ], |
@@ -95,13 +95,14 @@ discard block |
||
| 95 | 95 | try { |
| 96 | 96 | if ($msg = $this->cpeSqsListener->receive_message($queue, 10)) |
| 97 | 97 | { |
| 98 | - if (!($decoded = json_decode($msg['Body']))) |
|
| 99 | - $this->cpeLogger->log_out( |
|
| 98 | + if (!($decoded = json_decode($msg['Body']))) { |
|
| 99 | + $this->cpeLogger->log_out( |
|
| 100 | 100 | "ERROR", |
| 101 | 101 | basename(__FILE__), |
| 102 | 102 | "JSON data invalid in queue: '$queue'"); |
| 103 | - else |
|
| 104 | - $this->handle_message($decoded); |
|
| 103 | + } else { |
|
| 104 | + $this->handle_message($decoded); |
|
| 105 | + } |
|
| 105 | 106 | } |
| 106 | 107 | } catch (CpeSdk\CpeException $e) { |
| 107 | 108 | $this->cpeLogger->log_out( |
@@ -116,8 +117,9 @@ discard block |
||
| 116 | 117 | } |
| 117 | 118 | |
| 118 | 119 | // Message polled. Valid or not, we delete it from SQS |
| 119 | - if ($msg) |
|
| 120 | - $this->cpeSqsListener->delete_message($queue, $msg); |
|
| 120 | + if ($msg) { |
|
| 121 | + $this->cpeSqsListener->delete_message($queue, $msg); |
|
| 122 | + } |
|
| 121 | 123 | } |
| 122 | 124 | } |
| 123 | 125 | |
@@ -142,12 +144,13 @@ discard block |
||
| 142 | 144 | basename(__FILE__), |
| 143 | 145 | "Received message '" . $message->{"type"} . "'" |
| 144 | 146 | ); |
| 145 | - if ($this->debug) |
|
| 146 | - $this->cpeLogger->log_out( |
|
| 147 | + if ($this->debug) { |
|
| 148 | + $this->cpeLogger->log_out( |
|
| 147 | 149 | "DEBUG", |
| 148 | 150 | basename(__FILE__), |
| 149 | 151 | "Details:\n" . json_encode($message, JSON_PRETTY_PRINT) |
| 150 | 152 | ); |
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | // We call the callback function that handles this message |
| 153 | 156 | $this->{$this->typesMap[$message->{"type"}]}($message); |
@@ -161,12 +164,13 @@ discard block |
||
| 161 | 164 | // Start a new workflow in SWF to initiate new transcoding job |
| 162 | 165 | private function start_job($message) |
| 163 | 166 | { |
| 164 | - if ($this->debug) |
|
| 165 | - $this->cpeLogger->log_out( |
|
| 167 | + if ($this->debug) { |
|
| 168 | + $this->cpeLogger->log_out( |
|
| 166 | 169 | "DEBUG", |
| 167 | 170 | basename(__FILE__), |
| 168 | 171 | "Starting new workflow!" |
| 169 | 172 | ); |
| 173 | + } |
|
| 170 | 174 | |
| 171 | 175 | // Workflow info |
| 172 | 176 | $workflowType = array( |
@@ -218,13 +222,15 @@ discard block |
||
| 218 | 222 | !isset($message->{"time"}) || $message->{"time"} == "" || |
| 219 | 223 | !isset($message->{"jobId"}) || $message->{"jobId"} == "" || |
| 220 | 224 | !isset($message->{"type"}) || $message->{"type"} == "" || |
| 221 | - !isset($message->{"data"}) || $message->{"data"} == "") |
|
| 222 | - throw new CpeSdk\CpeException("'time', 'type', 'jobId' or 'data' fields missing in JSON message file!", |
|
| 225 | + !isset($message->{"data"}) || $message->{"data"} == "") { |
|
| 226 | + throw new CpeSdk\CpeException("'time', 'type', 'jobId' or 'data' fields missing in JSON message file!", |
|
| 223 | 227 | self::INVALID_JSON); |
| 228 | + } |
|
| 224 | 229 | |
| 225 | - if (!isset($message->{'data'}->{'workflow'})) |
|
| 226 | - throw new CpeSdk\CpeException("Input doesn't contain any workflow information. You must provide the workflow you want to send this job to!", |
|
| 230 | + if (!isset($message->{'data'}->{'workflow'})) { |
|
| 231 | + throw new CpeSdk\CpeException("Input doesn't contain any workflow information. You must provide the workflow you want to send this job to!", |
|
| 227 | 232 | self::INVALID_JSON); |
| 233 | + } |
|
| 228 | 234 | } |
| 229 | 235 | } |
| 230 | 236 | |
@@ -255,11 +261,13 @@ discard block |
||
| 255 | 261 | // Handle input parameters |
| 256 | 262 | $options = getopt("c:l:hdn:"); |
| 257 | 263 | |
| 258 | - if (isset($options['h'])) |
|
| 259 | - usage($defaultConfigFile); |
|
| 264 | + if (isset($options['h'])) { |
|
| 265 | + usage($defaultConfigFile); |
|
| 266 | + } |
|
| 260 | 267 | |
| 261 | - if (isset($options['d'])) |
|
| 262 | - $debug = true; |
|
| 268 | + if (isset($options['d'])) { |
|
| 269 | + $debug = true; |
|
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | $logPath = null; |
| 265 | 273 | if (isset($options['l'])) |
@@ -314,8 +322,7 @@ discard block |
||
| 314 | 322 | // Create InputPoller object |
| 315 | 323 | try { |
| 316 | 324 | $inputPoller = new InputPoller($config); |
| 317 | -} |
|
| 318 | -catch (CpeSdk\CpeException $e) { |
|
| 325 | +} catch (CpeSdk\CpeException $e) { |
|
| 319 | 326 | echo $e->getMessage(); |
| 320 | 327 | $cpeLogger->log_out( |
| 321 | 328 | "FATAL", |
@@ -326,5 +333,6 @@ discard block |
||
| 326 | 333 | } |
| 327 | 334 | |
| 328 | 335 | // Start polling loop to get incoming commands from SQS input queues |
| 329 | -while (42) |
|
| 336 | +while (42) { |
|
| 330 | 337 | $inputPoller->poll_SQS_queues(); |
| 338 | +} |
|
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | // Poll from all the taskList registered for each activities |
| 91 | 91 | if ($this->debug) |
| 92 | 92 | $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
| 93 | - "Polling activity taskList '" . $this->taskList . "' ... "); |
|
| 93 | + "Polling activity taskList '" . $this->taskList . "' ... "); |
|
| 94 | 94 | |
| 95 | 95 | try { |
| 96 | 96 | // Call SWF and poll for incoming tasks |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | if (!file_exists($activityToHandle->{"file"})) |
| 192 | 192 | { |
| 193 | 193 | $this->cpeLogger->log_out("ERROR", basename(__FILE__), |
| 194 | - "The code file '".$activityToHandle->{"file"}."' for activity: name=" |
|
| 194 | + "The code file '" . $activityToHandle->{"file"} . "' for activity: name=" |
|
| 195 | 195 | . $activityToHandle->{"name"} . ",version=" |
| 196 | - . $activityToHandle->{"version"}." doesn't exists! Check if the file is accessible and if the path is correct in your config file."); |
|
| 196 | + . $activityToHandle->{"version"} . " doesn't exists! Check if the file is accessible and if the path is correct in your config file."); |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $this->cpeLogger->log_out("ERROR", basename(__FILE__), |
| 228 | 228 | "No Activity handler was found for: name=" |
| 229 | 229 | . $this->activityName . ",version=" |
| 230 | - . $this->activityVersion.". Check your config file and ensure your 'activity' name AND 'version' is there."); |
|
| 230 | + . $this->activityVersion . ". Check your config file and ensure your 'activity' name AND 'version' is there."); |
|
| 231 | 231 | return false; |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | // Usage |
| 246 | 246 | function usage($defaultConfigFile) |
| 247 | 247 | { |
| 248 | - echo("Usage: php ". basename(__FILE__) . " -D <domain> -T <task_list> -A <activity_name> -V <activity_version> [-h] [-d] [-c <config_file path>] [-l <log path>]\n"); |
|
| 248 | + echo("Usage: php " . basename(__FILE__) . " -D <domain> -T <task_list> -A <activity_name> -V <activity_version> [-h] [-d] [-c <config_file path>] [-l <log path>]\n"); |
|
| 249 | 249 | echo("-h: Print this help\n"); |
| 250 | 250 | echo("-d: Debug mode\n"); |
| 251 | 251 | echo("-c <config_file path>: Optional parameter to override the default configuration file: '$defaultConfigFile'.\n"); |
@@ -78,8 +78,9 @@ discard block |
||
| 78 | 78 | $this->cpeSwfHandler = new CpeSdk\Swf\CpeSwfHandler($this->debug); |
| 79 | 79 | |
| 80 | 80 | // Check and load activities to handle |
| 81 | - if (!$this->register_activities()) |
|
| 82 | - die("No activity class registered! Check the logs (/var/tmp/logs/cpe/). Exiting ...\n"); |
|
| 81 | + if (!$this->register_activities()) { |
|
| 82 | + die("No activity class registered! Check the logs (/var/tmp/logs/cpe/). Exiting ...\n"); |
|
| 83 | + } |
|
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | // We poll for new activities |
@@ -88,9 +89,10 @@ discard block |
||
| 88 | 89 | public function poll_for_activities() |
| 89 | 90 | { |
| 90 | 91 | // Poll from all the taskList registered for each activities |
| 91 | - if ($this->debug) |
|
| 92 | - $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
|
| 92 | + if ($this->debug) { |
|
| 93 | + $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
|
| 93 | 94 | "Polling activity taskList '" . $this->taskList . "' ... "); |
| 95 | + } |
|
| 94 | 96 | |
| 95 | 97 | try { |
| 96 | 98 | // Call SWF and poll for incoming tasks |
@@ -114,8 +116,9 @@ discard block |
||
| 114 | 116 | { |
| 115 | 117 | // Get activityType and WorkflowExecution info |
| 116 | 118 | if (!($activityType = $activityTask->get("activityType")) || |
| 117 | - !($workflowExecution = $activityTask->get("workflowExecution"))) |
|
| 118 | - return false; |
|
| 119 | + !($workflowExecution = $activityTask->get("workflowExecution"))) { |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 119 | 122 | |
| 120 | 123 | $this->cpeLogger->log_out("INFO", |
| 121 | 124 | basename(__FILE__), |
@@ -142,16 +145,18 @@ discard block |
||
| 142 | 145 | // Perform input validation |
| 143 | 146 | $this->activityHandler->do_input_validation(); |
| 144 | 147 | |
| 145 | - if ($this->debug) |
|
| 146 | - $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
|
| 148 | + if ($this->debug) { |
|
| 149 | + $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
|
| 147 | 150 | "Activity input:\n" . print_r($this->activityHandler->input, true)); |
| 151 | + } |
|
| 148 | 152 | |
| 149 | 153 | // Run activity task |
| 150 | 154 | $result = $this->activityHandler->do_activity($activityTask); |
| 151 | 155 | |
| 152 | - if ($this->debug && $result) |
|
| 153 | - $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
|
| 156 | + if ($this->debug && $result) { |
|
| 157 | + $this->cpeLogger->log_out("DEBUG", basename(__FILE__), |
|
| 154 | 158 | "Activity output:\n" . print_r($result, true)); |
| 159 | + } |
|
| 155 | 160 | |
| 156 | 161 | } catch (CpeSdk\CpeException $e) { |
| 157 | 162 | $reason = $e->ref; |
@@ -270,15 +275,18 @@ discard block |
||
| 270 | 275 | global $activityVersion; |
| 271 | 276 | |
| 272 | 277 | // Handle input parameters |
| 273 | - if (!($options = getopt("D:T:A:V:c:l:hd"))) |
|
| 274 | - usage($defaultConfigFile); |
|
| 278 | + if (!($options = getopt("D:T:A:V:c:l:hd"))) { |
|
| 279 | + usage($defaultConfigFile); |
|
| 280 | + } |
|
| 275 | 281 | |
| 276 | - if (!count($options) || isset($options['h'])) |
|
| 277 | - usage($defaultConfigFile); |
|
| 282 | + if (!count($options) || isset($options['h'])) { |
|
| 283 | + usage($defaultConfigFile); |
|
| 284 | + } |
|
| 278 | 285 | |
| 279 | 286 | // Debug |
| 280 | - if (isset($options['d'])) |
|
| 281 | - $debug = true; |
|
| 287 | + if (isset($options['d'])) { |
|
| 288 | + $debug = true; |
|
| 289 | + } |
|
| 282 | 290 | |
| 283 | 291 | // Domain |
| 284 | 292 | if (!isset($options['D'])) |
@@ -348,8 +356,7 @@ discard block |
||
| 348 | 356 | // Instantiate ActivityPoller |
| 349 | 357 | try { |
| 350 | 358 | $activityPoller = new ActivityPoller($config); |
| 351 | -} |
|
| 352 | -catch (CpeSdk\CpeException $e) { |
|
| 359 | +} catch (CpeSdk\CpeException $e) { |
|
| 353 | 360 | $cpeLogger->log_out("FATAL", |
| 354 | 361 | basename(__FILE__), $e->getMessage()); |
| 355 | 362 | exit(1); |
@@ -358,6 +365,7 @@ discard block |
||
| 358 | 365 | $cpeLogger->log_out("INFO", basename(__FILE__), "Starting activity tasks polling"); |
| 359 | 366 | |
| 360 | 367 | // Start polling loop |
| 361 | -while (42) |
|
| 368 | +while (42) { |
|
| 362 | 369 | $activityPoller->poll_for_activities(); |
| 370 | +} |
|
| 363 | 371 | |
@@ -134,7 +134,7 @@ |
||
| 134 | 134 | $CpeClientSdk = new SA\CpeClientSdk($key, $secret, $region, $debug); |
| 135 | 135 | } catch (Exception $e) { |
| 136 | 136 | exit($e->getMessage()); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | // Commands mapping |
| 140 | 140 | $commandMap = [ |