public function commit() { $siteId = Input::get('siteId'); $commit = Input::get('commit'); $hostType = Input::get('remote'); $deploy = array('branch' => '---', 'commit' => $commit, 'hosttype' => $hostType, 'user' => GithubLogin::getLoginUser()->login, 'type' => 'Deploy To ' . $hostType, 'time' => date('Y-m-d H:i:s'), 'last_time' => '0000-00-00 00:00:00', 'result' => 'Deploy Waiting', 'errMsg' => ' ', 'errOut' => "<div class='text-center'>----------- ERROR OUTPUT -----------</div>\n", 'standOut' => "<div class='text-center'>----------- STANDED OUTPUT -----------</div>\n"); $id = (new DeployInfo($siteId))->add($deploy); $class = Config::get('worker.queue.deploy'); Supervisor::push($class, array('siteId' => $siteId, 'commit' => $commit, 'hostType' => $hostType, 'id' => $id), 'deploy'); return Response::json(array('res' => 0)); }
/** * Execute the console command. * * @return mixed */ public function fire() { $queue = $this->argument('queue'); if (empty($queue)) { $queue = 'default'; } $pid = getmypid(); Log::info("New Worker Start, pid {$pid}, queue {$queue}"); $handler = function ($signal) { if ($signal = SIGINT) { echo "You can't stop Worker here\n"; } elseif ($signal = SIGHUP) { Log::info("RECV SIGHUP"); } }; pcntl_signal(SIGINT, $handler); pcntl_signal(SIGHUP, $handler); // php-fpm stop 的时会发送这个信号 $queue = new ElemeJobQueue($queue); $supervisor = new Supervisor($queue, $pid); $worker = $supervisor->getWorker(); $worker->listen(); }
public function toDeploy($siteId) { $commit = Input::get('commit'); $hostType = Input::get('remote'); $date = date('Y-m-d H:i:s'); $user = GithubLogin::getLoginUser(); $pr = new PullRequest($siteId); $prCommit = $pr->get($commit); $prd = new PullRequestDeploy($siteId); $pri = $prd->add($prCommit->prId, $prCommit->title, $commit, $prCommit->user, $user->login, $hostType, $date, $date, 'Waiting'); //Queue::push('DeployCommit', array('id' => $pri->id, 'type' => DeployCommit::TYPE_PULL_REQUEST, 'hostType' => $hostType, 'siteId' => $siteId, 'commit' => $commit), DeployInfo::DEPLOY_QUEUE); $class = Config::get('worker.queue.deploy'); Supervisor::push($class, array('siteId' => $siteId, 'commit' => $commit, 'type' => DeployCommit::TYPE_PULL_REQUEST, 'hostType' => $hostType, 'id' => $pri->id), 'deploy'); return Response::json(array('res' => 0)); }
$m->status = 'closed'; $pr->save($m); } } elseif ($notifyObject->action == 'reopened') { $commitList = $pr->getListByPRId($notifyObject->pull_request->id); foreach ($commitList as $m) { $m->status = 'open'; $pr->save($m); } } $have->status = $notifyObject->pull_request->state; $pr->save($have); } else { //Queue::push('PullRequestBuild', array('siteId' => $siteId, 'commit' => $commit), DeployInfo::PR_BUILD_QUEUE); $class = Config::get('worker.queue.prbuild'); \Eleme\Worker\Supervisor::push($class, array('siteId' => $siteId, 'commit' => $commit, 'pullNumber' => $pullNumber), 'prbuild'); $pr->add($notifyObject); } } } return ""; }); Route::get('/github/oauth/confirm', function () { if (GithubLogin::check()) { return Redirect::to('/'); } return Response::view('oauth-confirm'); }); Route::get('/github/oauth', function () { if (GithubLogin::check()) { return Redirect::to('/');