Skip to content

Commit 71ee020

Browse files
committed
DeployRunner: Add SIGINT handler to run fail tasks
Works like this: ``` $ hypernode-deploy deploy production task deploy:info [production:example.hypernode.io] info deploying HEAD task prepare:ssh task deploy:info [production:example.hypernode.io] info deploying HEAD task deploy:setup task deploy:lock task deploy:release task deploy:shared task deploy:writable task deploy:copy:code ^C[warning] Received signal SIGINT, running fail jobs [production:example.hypernode.io] error in CopyTask.php on line 20: [production:example.hypernode.io] run readlink /data/web/apps/example/release [production:example.hypernode.io] exit code -1 (Unknown error) task deploy:failed task deploy:unlock ```
1 parent f74f7ff commit 71ee020

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/DeployRunner.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ private function runStage(Deployer $deployer, string $stage, string $task = 'dep
303303
$tasks = $deployer->scriptManager->getTasks($task);
304304
$executor = $deployer->master;
305305

306+
pcntl_signal(SIGINT, function () {
307+
$this->log->warning("Received signal SIGINT, running fail jobs");
308+
// We don't have to do anything here. Underlying processes will receive the SIGINT signal as well
309+
// and that will cause the $exitCode below to be 255, which will cause the fail tasks to be run.
310+
});
311+
306312
/**
307313
* Set the env variable to tell deployer to deploy the hosts sequentially instead of parallel.
308314
* @see \Deployer\Executor\Master::runTask()

0 commit comments

Comments
 (0)