OAProfessor

Deep OA Product Insight

User Tools

Site Tools


shutdown

SCADA systems are usually run 7x24x365. There are some cases when we want to shutdown a project and maybe even the computer. I encountered this case for a system running on a big UPS. Unlike the home UPS, this system had _address config DPE that told us 2 things, first was when we were running on battery, and secondly, when the battery was getting low.

We know that yanking out a cord MIGHT leave the project and/or the operating system in a bad state. OA will usually repair itself but if you look at the Microsoft website, they do not guarantee that the system will boot again. IF you are using the ValueArchives (old database), you can reduce the risk of loosing data by using the following config file entry (it does slow down the ValueArchives)

[data]
transactionLogging = 1

Now you have to think about how you want to handle the shutdown. Here are some options:

  • Let the system run out of power and the computer stop
  • If you have redundancy, stop the backup project and computer so at least 1/2 of your servers are sure to come up
  • ask the operator if they want to stop the project

Regardless of your choice, there are some tricky things when you try to stop a project from scripting.

Any scripts you run should run independently on the servers. Here is the Control Manager options for starting a script that runs on EACH server in a redundant pair:

ServerMonitor.ctl -connectToRedundantHosts

Here is the way you can determine if you are the master in a redundant pair:

//#uses "pmon"    // I think you need these at the top of your script
//#uses "dist"
int reduStat;
string serverNames;
reduActive(reduStat);
serverNames = eventHost();
if(reduStat > 0)                                // redundant mode
{
  if(mySvrName == serverNames[reduStat])      // this will be the master
    backupServer = FALSE;
  else
    backupServer = TRUE;
}    

Once you have all of the decisions made and logic set for stopping the project and/or the computer, here is some code for stopping the computer with a delay so if you need to stop the project, the project will still be running:

int sysRet;
sysRet = system("start /b shutdown /s /t 60");        // sends shutdown computer with delay of 60 seconds 
if(sysRet < 0)
  DebugN("problem sending computer shutdown request");  

This is for windows, there is a similar shutdown call for Linux, refer to the linux version you are using for details. While the system is waiting, you can send the shutdown for the project

// send shutdown command to the pmon to start orderly shutdown of project and get all files closed
string sConfig;
paProjName2ConfigFile(PROJ, sConfig);
sysRet = system(PVSS_BIN_PATH+getComponentName(PMON_COMPONENT)+" -stopWait -config " + sConfig); 
if(sysRet < 0)
  DebugN("problem sending MCCS project shutdown request");  
  

Ensuring that you have an orderly shutdown for the project and computer will ensure that when power is restored, the system will recover.

shutdown.txt · Last modified: 2021/12/29 20:41 by toddmalone

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki