Return the PID used for the Ignition service in Linux install?

Is it possible to use system.util.execute or some other wizardry to return the process ID that the Ignition gateway is running under, in the underlying linux installation.
For reference i am running Ignition on an Ubuntu VM.
Currently i can extract this using “top” command in Ubuntu and identify the PID as follows:

So in this case it is 1421.

Also, can anything be done to name it something more useful than just “Java”?

I need this for… reasons. Namely trying to run a shell script to start a Java Flight Recording to identify gateway performance issues. Automatically. Similar to how a Thread Dump would be request when gateway CPU / RAM is going higher than expected.

I’ve managed to execute my shell script automatically which is nice, but currently the PID is hardcoded as 1421, which will not be so nice after the service / VM restarts.

While Ignition is running there should be an Ignition-Gateway.pid file or something like that in the directory Ignition is installed and running from.

When the service starts, there will be a file that contains the PID of the Java Service Wrapper:

From there you should be able to use pgrep -P $(cat Ignition-Gateway.pid) to return the java process ID:

4 Likes

Ah perfect, thank you. Learn something new every day.

But we can’t return anything from system.util.execute, so is there a way to get a value from a command line script into Ignition?

See this topic and Paul's linked topic within it:

Perhaps:

from java.lang import ProcessHandle
pid = ProcessHandle.current().pid()
2 Likes

Lovely, that worked perfectly! Awesome stuff.