Example #1
0
 /**
  * {@inherit}
  *
  * {@inherit}
  */
 public function call(array $options = [])
 {
     $cmd = "php " . $this->script;
     $cmd .= Script::makeParamsString(['scriptOptions' => Script::encodeParams($options)]);
     $cmd .= "  > /dev/null 2>&1 & echo \$!";
     $output = trim(shell_exec($cmd));
     if (!is_numeric($output)) {
         throw new CallbackException("The output of the script is ambiguous. Probably there is an error in the script");
     }
     $pId = intval($output);
     $itemData = ['pid' => $pId, 'startedAt' => UTCTime::getUTCTimestamp(), 'scriptName' => "Worker: ", 'timeout' => 30];
     $this->dataStore->create($itemData);
     return $pId;
 }
Example #2
0
 /**
  * Translates the "update" call to DataStore
  *
  * @see \zaboy\scheduler\Callback\Factory\DataStoreAbstractFactory
  * @see \zaboy\rest\DataStore\Interfaces\DataStoresInterface
  * @param array $options
  * @return array
  */
 private function update(array $options = [])
 {
     $itemData = $options['item_data'];
     $createIfAbsent = isset($options['flags']['createIfAbsent']) ? $options['flags']['createIfAbsent'] : false;
     return $this->dataStore->create($itemData, $createIfAbsent);
 }
 /**
  * Fills table by data from config
  *
  * TODO: уйдет из этого класса, пока не известно, куда, но здесь этого кода быть не должно
  *
  * @param ContainerInterface $serviceLocator
  * @throws DataStoreException
  */
 protected function fillTable(ContainerInterface $container, DataStoreAbstract $dataStore)
 {
     $config = $container->get('config');
     // If configs for tasks doesn't exist do nothing
     if (!isset($config[self::KEY_TASKS])) {
         return;
     }
     $id = $dataStore->getIdentifier();
     foreach ($config[self::KEY_TASKS] as $task) {
         if (!isset($task[$id])) {
             throw new DataStoreException("Expected necessary parameter \"{$id}\" in data of filter");
         }
         $dataStore->create($task);
     }
 }