neo4j-devtools / neo4j-desktop

The Neo4j Graph Platform, on your desktop OS.
19 stars 1 forks source link

Process started by neo4jDesktopApi.executeNode stays running after app is closed #26

Open nossila opened 6 years ago

nossila commented 6 years ago

How can I kill the process when the user closes the app?

I tried to do something like:

function killNodeProcess() {
  nodeProcess.kill();
}

window.addEventListener("beforeunload", killNodeProcess);
// or
window.addEventListener("unload", killNodeProcess);

I see this working when reloading the app, but when closing the my app window the process don't get killed, I need to close Neo4j Desktop for it to get killed.

Maybe Neo4j Desktop should by default kill any process started by an app when this app gets closed.

Metaur commented 6 years ago

If you refer to the official docs, you'll notice that there is no function kill available for node processes. Use nodeProcess.stop() instead. It will try to stop the process gracefully first. If that won't work, Desktop will kill the process.

Once Desktop is closed - all subprocesses (neo4j, java, node) are being stopped automatically. I like the idea of stopping processes populated by the graph app once the window is closed.

nossila commented 6 years ago

The Process object have a nodeProcess key which have a kill function, that's what I was using, I forgot to mention that. I updated my code to use nodeProcess.stop() instead since this is the recommended one but the behavior looks the same, process is stopped for reloading but don't stop when closing the app.

Metaur commented 6 years ago

@nossila what would be the expected Desktop behaviour then? Closing a graph app window stops all populated processes? Or those processes should continue running in the background, but then Desktop would give a descriptor for each running background process once you open the graph app again?

nossila commented 6 years ago

@Metaur as an user I would like to be able to free all resources used by an app when closing it, so I would vote for stopping the processes when closing their parent graph app.