The Process Facet

3 min read

3 min read

3 min read

3 min read

3 min read

The Process facet lets a location service, such as IceGrid, request a graceful shutdown of a server. The communicator can register a proxy for this facet with the location service, as described in Registering the Process Facet with the Location Service.

The Process facet implements the Ice::ProcessIce::ProcessIce::ProcessIce::ProcessIce::ProcessIce::ProcessIce::ProcessIce::Process interface:

  • shutdown initiates a graceful shutdown of the program, which can take some time to complete. An IceGrid node that calls shutdown terminates the server when the shutdown takes too long.
  • writeMessage prints a message to the program's standard output (fd 1) or standard error (fd 2).

The default Process facet calls shutdown on the communicator. This shuts down the server through a convention that Ice servers follow: the shutdown of the communicator is the signal to exit. The main thread of the server waits for this shutdown, for example by calling waitForShutdown, then cleans up and exits.

To shut the program down differently, replace the default Process facet with a servant that implements Ice::Process. Set Ice.Admin.DelayCreation to 1, so that the communicator does not create the admin object during initialization:

Properties
Ice.Admin.DelayCreation=1

Then remove the default facet, add your own, and call getAdmin to create the admin object:

C++
// MyProcess implements Ice::Process
auto myProcessFacet = std::make_shared<MyProcess>(...);
communicator->removeAdminFacet("Process");
communicator->addAdminFacet(myProcessFacet, "Process");
communicator->getAdmin();
C#
// MyProcess implements Ice.Process
var myProcessFacet = new MyProcess(...);
communicator.removeAdminFacet("Process");
communicator.addAdminFacet(myProcessFacet, "Process");
communicator.getAdmin();
Java
// MyProcess implements com.zeroc.Ice.Process
var myProcessFacet = new MyProcess(...);
communicator.removeAdminFacet("Process");
communicator.addAdminFacet(myProcessFacet, "Process");
communicator.getAdmin();
Python
# MyProcess implements Ice.Process
myProcessFacet = MyProcess(...)
communicator.removeAdminFacet("Process")
communicator.addAdminFacet(myProcessFacet, "Process")
communicator.getAdmin()
Swift
// MyProcess implements Ice.Process
let myProcessFacet = MyProcess(...)
try communicator.removeAdminFacet("Process")
try communicator.addAdminFacet(servant: myProcessFacet, facet: "Process")
_ = try communicator.getAdmin()

If Ice.Admin.ServerId is set and the communicator has a default locator, the communicator registers a proxy for the Process facet with the locator registry after creating the admin object, by calling setServerProcessProxy with the value of Ice.Admin.ServerId.

With IceGrid, this value is the ID of the server in its deployment: IceGrid sets Ice.Admin.ServerId and Ice.Default.Locator for each server that it deploys. When the descriptor of the server defines neither Ice.Admin.Endpoints nor Ice.Admin.Enabled, IceGrid also sets Ice.Admin.Endpoints to tcp -h 127.0.0.1.