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 Interface
Process InterfaceThe Process facet implements the Ice::ProcessIce::ProcessIce::ProcessIce::ProcessIce::ProcessIce::ProcessIce::ProcessIce::Process interface:
shutdowninitiates a graceful shutdown of the program, which can take some time to complete. An IceGrid node that callsshutdownterminates the server when the shutdown takes too long.writeMessageprints a message to the program's standard output (fd1) or standard error (fd2).
Graceful Shutdown
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.
Replacing the Process Facet
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:
Ice.Admin.DelayCreation=1Then remove the default facet, add your own, and call getAdmin to create the admin object:
// MyProcess implements Ice::Processauto myProcessFacet = std::make_shared<MyProcess>(...);
communicator->removeAdminFacet("Process");communicator->addAdminFacet(myProcessFacet, "Process");communicator->getAdmin();// MyProcess implements Ice.Processvar myProcessFacet = new MyProcess(...);
communicator.removeAdminFacet("Process");communicator.addAdminFacet(myProcessFacet, "Process");communicator.getAdmin();// MyProcess implements com.zeroc.Ice.Processvar myProcessFacet = new MyProcess(...);
communicator.removeAdminFacet("Process");communicator.addAdminFacet(myProcessFacet, "Process");communicator.getAdmin();# MyProcess implements Ice.ProcessmyProcessFacet = MyProcess(...)
communicator.removeAdminFacet("Process")communicator.addAdminFacet(myProcessFacet, "Process")communicator.getAdmin()// MyProcess implements Ice.Processlet myProcessFacet = MyProcess(...)
try communicator.removeAdminFacet("Process")try communicator.addAdminFacet(servant: myProcessFacet, facet: "Process")_ = try communicator.getAdmin()Registering the Process Facet with the Location Service
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.