Question Antonio Garcia Martinez · Jan 29, 2018

Disable Service/Process/Operation from a function?

Hi,

I am working on a custom service that reads from a file and import content into a global. The problem is that global is also used by other processes. I have been trying to find any way to stop/disable a process from cache code so after reading the file, process is stopped, global updated and then process is restored. But I could not find anything, just to start/stop the whole production 

Do ##class(Ens.Director).StopProduction()

Any ideas if this is something that can be done in ensemble?

Thanks

Comments

Chris Thompson · Jan 29, 2018

Look into ##class(Ens.Director).EnableConfigItem

0
Antonio Garcia Martinez  Jan 30, 2018 to Eduard Lebedyuk

In my case, processes accessing the global are just to read data from global, the global will not be changed by them. It is just once a month the global needs to be updated and only then is when the locks would be required.

0
Eduard Lebedyuk  Jan 30, 2018 to Antonio Garcia Martinez

Remove the lock before starting Ensemble service.

0
Eduard Lebedyuk · Jan 29, 2018

Have you checked Locks? If more than one process works with the same global locks are the way to go.

0
Antonio Garcia Martinez · Jan 30, 2018

Thank you both for your quick replies.

That was exactly what I was looking for....

I think I will be using both...one to stop the other processes accessing the global + locks to really ensure no other processes access the global.

 

My code will be something like the following:

// Stop other ensemble jobs accessing to the global to avoid bad messages. 
// Jobs are such as services/processes/operations by name. 
DO ##class(Ens.Director).EnableConfigItem("xxx",0,0)
$$$LOGINFO("xxx Disabled")

// Add a lock to control access to the global.
// 0 => 1 attemp only.
LOCK +^lockname:0
// If lock is unsuccesfull, $TEST variable = 0
If '$TEST {
$$$LOGERROR("Lock cannot be obtained. Process cannot continue.")
Quit tSC 
}
$$$LOGINFO("LOCK on")



*** code here to update global ***



// Start other ensemble jobs accessing to the global to avoid bad messages. 
// Jobs are such as services/processes/operations by name. 
DO ##class(Ens.Director).EnableConfigItem("xxx",1,0)
$$$LOGINFO("xxx Enabled")

// REmove lock to control access to the global.
LOCK -^lockname
$$$LOGINFO("LOCK off")
0