Esempio n. 1
0
 /**
  * Runs the job in background.
  * @see http://symfony.com/doc/current/components/process.html
  * 
  * @param Job $job
  * @return Crontab
  */
 public function run(Job $job)
 {
     $command = $job->getCommand();
     if (At::isAvailable()) {
         $command = sprintf('sh -c "echo "%s" | at now"', $job->getCommand());
     }
     $process = new Process($command);
     $process->start();
     return $this;
 }
Esempio n. 2
0
// as the view for non-XHR requests
$view = new \library\App\Layout();
$view->setTemplatesDirectory($app->config('templates.path'));
$app->config('view', $view);
if (!$app->request->isXhr()) {
    $app->view($view);
}
// Routes
$app->get('/', function () use($app) {
    $crontab = new Crontab();
    $systemUser = new SystemUser();
    $simpleForm = new AddJob\SimpleForm();
    $advancedForm = new AddJob\AdvancedForm();
    $showAlertAtUnavailable = $app->getCookie('showAlertAtUnavailable');
    $app->view->setData('showAlertAtUnavailable', $showAlertAtUnavailable !== null ? (bool) $showAlertAtUnavailable : true);
    $app->render('index.phtml', array('crontab' => $crontab, 'systemUser' => $systemUser, 'isAtCommandAvailable' => At::isAvailable(), 'atCommandErrorOutput' => At::getErrorOutput(), 'simpleForm' => $simpleForm, 'advancedForm' => $advancedForm));
});
/**
 * Groups cron job related routes.
 */
$app->group('/job', function () use($app) {
    /**
     * Should be used as a route middleware to allow for the response
     * to be JSON in the route's callable.
     * 
     * @return void
     */
    $setupJsonResponse = function () {
        $app = \Slim\Slim::getInstance();
        $app->add(new \SlimJson\Middleware());
    };