0

I've got into a scenario in which I want to stop a currently executing java process in custom Azure VM. The VM is a ubuntu machine which is configured by our Infra.

I'm building a Azure - Continuous Deployment pipeline in which I want to deploy the latest build in the VM. But before I could deploy the latest build, I need to bring down the currently executing Java Process of previous build.

I was using "Command Over SSH" to trigger a 'kill' signal with the process ID of the java process, but Azure forbids use of 'kill' command in a pipeline.

Logs

==============================================================================
Task         : SSH
Description  : Run shell commands or a script on a remote machine using SSH
Version      : 0.165.1
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/ssh
==============================================================================
Trying to establish an SSH connection to ***@<HOST>:22
Successfully connected.
chmod +x "./sshscript_158452036****"
"./sshscript_158452036****"
 ========** Stop currently executing process: 4381

##[error]./sshscript_158452036****: line 5: kill: (4381) - Operation not permitted

Is there any other way to gracefully bring down the Java Process. OR Achieve the CD with some other solution. I'm not planning to Dockerize the deployment.

Thanks !

Debadatta Meher
  • 83
  • 2
  • 10

1 Answers1

0

The "Operation not permitted" error is not coming from Azure. Instead it means that your ssh user does not have permissions to kill that process on the VM. So the existing process is run by different user than the one you're using to ssh.

Possible workaround - include some sort of cron with your old deployment which would scan for a trigger file (say /tmp/killmyprocess.trigger), and if file is present - would kill it.

And then in your new deployment all you do is just do

touch /tmp/killmyprocess.trigger
taleodor
  • 1,849
  • 1
  • 13
  • 15
  • Thanks for your suggestion. Indeed the issue was because of different user trying to kill the exec. process. I fixed this issue by executing the process with same user with which I've built the pipeline. It's working fine now. – Debadatta Meher Mar 19 '20 at 08:56