JANOS Register Process
Written by Kevin Cloutier on Sep 15, 2022 3:57 pm
Many times we write an application that should be the only instance of that application running. That application may monitor inputs, control outputs, send email, or perform logic. Whatever that application is doing, it should be the only one doing that particular thing at any given time.
The ensure that this happens we use the JANOS.registerProcess(id)
method. This method returns the number of processes that have been registered with that given id
. That id
can be any unique identifier given to that application. It can be a name or a random UUID.
If the registerProcess()
method returns a value greater than one then we will exit our application. This will leave the first instance running. Here is an example.
// make sure there is only 1 instance of this application running
if (1 < JANOS.registerProcess(Application.getAppName())) {
JANOS.syslog("Another instance of " + Application.getAppName() + " is running");
}
On this page
Tags