Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Functions local process not killed properly on Mac/IntelliJ #6374

Closed
justinyoo opened this issue Feb 2, 2022 · 9 comments
Closed

Azure Functions local process not killed properly on Mac/IntelliJ #6374

justinyoo opened this issue Feb 2, 2022 · 9 comments

Comments

@justinyoo
Copy link

Hi, Team.

I'm not sure this is the issue from this plugin or IntelliJ itself, but I'd like to create an issue here. Here's my dev environment:

  • Mac OS (Monterey; 12.2)
  • IntelliJ CE (2021.3.2)
  • Azure Tools for IntelliJ 3.61.1 - 2021.3
  • Azure Functions Core Tools v4 4.0.3971

Here's how to reproduce the error:

  1. Run an Azure Functions app from IntelliJ.
  2. Confirm that it takes the port of 7071.
  3. Stop the app.
  4. Re-run the Azure Functions app from IntelliJ.
  5. Confirm that the port 7071 is still occupied by another process.

image

Therefore, in order to re-run the Function app, I have to manually find and kill the process every time. Here's what I use to kill the process:

https://gist.github.com/justinyoo/045201b2c4280c818ca872af6284c720

I google'd whether it's the issue of IntelliJ itself or this plugin, and found these threads:

Although they're a bit old conversations, apparently other devs are experiencing similar issues. So, I checked the code how it's handled and found it:

private static void stopProcessIfAlive(final Process proc) {
if (proc != null && proc.isAlive()) {
proc.destroy();
}
}

As I'm not a Java dev, I don't know what the code exactly means. But, I suspect that the code doesn't kill all the child processes. Because Azure Functions runtime takes at least two processes - main for the runtime itself and one sub process for the language worker, when the tool stops the process it should stop all the processes including main and its sub.

it would be great if you can take a look.

@Flanker32
Copy link
Member

@justinyoo Thanks a lot for your report and investigation, we will looking into this issue, and will update here once there are updates.

@wcom939
Copy link

wcom939 commented Feb 7, 2022

This also occurs on Windows

@justinyoo
Copy link
Author

This also occurs on Windows

It's not the case to me. I only see this issue on Mac OS.

@Flanker32
Copy link
Member

@wcom939 Thanks for your information, could you please share some more info like the function core tools and toolkit version?

@wcom939
Copy link

wcom939 commented Feb 22, 2022

It occurred for me when closing intellij while not terminating the run dialog. I had to restart my PC to clear it. Running windows 11.

Azure Functions Core Tools
Core Tools Version: 4.0.3971 Commit hash: d0775d487c93ebd49e9c1166d5c3c01f3c76eaaf (64-bit)
Function Runtime Version: 4.0.1.16815

image

@Flanker32
Copy link
Member

@wcom939 Thanks for your report, azure toolkit will run function core tools in a new process and close it when you close terminate the run configuration, but this may not work if you close intellij directly, will investigate how to kill the process in this case.

@Flanker32
Copy link
Member

@justinyoo Thanks again for your help, this issue should be resolved in the latest release v3.62.0, beside we also support set the func port manually, could you please upgrade to the latest version and try again?

@no-response
Copy link

no-response bot commented Mar 17, 2022

This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Mar 17, 2022
@braxtonstuart
Copy link

braxtonstuart commented Sep 2, 2022

FYI - I am still experiencing these issues on macOS.

IntelliJ IDEA 2022.2.1 Ultimate Edition
Azure Toolkit for Intellij 3.68.0-2022.2

Azure Functions Core Tools
Core Tools Version: 4.0.4736 Commit hash: N/A (64-bit)
Function Runtime Version: 4.8.1.18957

Screen Shot 2022-09-02 at 3 52 57 PM

Thanks @justinyoo for the including the bash commands to kill the process... saved me from having to dig up the lsof input params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants