if (!isset($app_path)) { \ServerBench\Cli\printf_and_exit("arugment --app should be set.\n"); } if (!file_exists($app_path)) { \ServerBench\Cli\printf_and_exit("app(%s) does not exist.", $app_path); } if (!isset($arguments['ipcs'])) { \ServerBench\Cli\printf_and_exit("argument --ipcs should be set.\n"); } $ipcs = explode(',', $arguments['ipcs']); if (count($ipcs) != 2) { \ServerBench\Cli\printf_and_exit("argument --ipcs should be a couple of sock files.\n"); } ProcessUtil::setTitle($arguments->get('title', 'serverbench<worker>')); try { $api = new Api('worker', include $app_path); if (false === $api->init()) { \ServerBench\syslog_error('app->init(\'worker\') returns false.'); exit; } PeriodicGc::enable(300); $worker = new Worker($ipcs, function ($message) use($api) { return $api->process($message); }); $worker->run(); if (false === $api->fini()) { \ServerBench\syslog_error('app->fini(\'worker\') returns false.'); } } catch (Exception $e) { \ServerBench\syslog_error('uncaught exception from worker: %s', [$e]); }