deployer
deployer copied to clipboard
Aborting a task by CTRL+C leaves the process running on the server
- Deployer version: 7.0.0-rc.8
- Deployment OS: Ubuntu 18.04.6 LTS
I'm not sure if this is the desired behavior, since I discovered it by applying deployer to a rather non-standard task.
In addition to directly deploying and provisioning, I created several handy tasks for debugging, among them displaying the application log in real time. The task runs something like tail -f file.log
. It's very handy to run dep log my-host
and see the log in real time. But when I press CTRL+C, even though the task stops in the console, the tail process continues to run on the server.
It turns out that interrupting the long task doesn't actually stop the process on the server, but only returns a prompt in the console.
Should this behavior be fixed? Can anyone suggest a workaround to solve my problem?
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Yes, I think it should be fixed.
This is the default ssh behavior. But Deployer has a special timeout feature and this can be repurposed to also handle CTRL+C.
Yes, I think it should be fixed.
This is the default ssh behavior. But Deployer has a special timeout feature and this can be repurposed to also handle CTRL+C.
Is there some sort of temporary workaround for this?
Implement your own abort handler as its just php code.
Implement your own abort handler as its just php code.
Okay, but what should I do inside this handler? I think I need to run kill [pid]
, but I don't know the process id. The only possible option is to grep process id by command name?
This is what Deployer does internally on timeout.
This is what Deployer does internally on timeout.
Ah, got it, thanks.
I can't get this to work. I set the signal handler in the task, it is set, but it is not called when I press CTRL-C:
declare(ticks = 1);
task('app:log', function () {
$command = parse('...');
pcntl_signal(SIGINT, function () use ($command) {
echo 'Got SIGINT';
exit;
});
cd('{{project_path}}');
run($command);
});
The same code works if the call to pcntl_signal is placed outside the task. But outside the task context it will be hard to understand which task is active at the moment.
In addition, I cannot call run() inside the signal handler, I get the error "Context was requested but was not available". Can you give me a link to an example where you do this to handle timeout?