Home Help Center

Ice::Process

marksnellingmarksnelling Member Mark SnellingOrganization: Winton Capital ManagementProject: Trading System
I'm relatively new to Ice so please excuse me if I have this completely wrong.

I have an existing application that I want to add an Ice interface to. I have this working well so I have decided to start playing with the IceGrid stuff.

I have IceGridAdmin starting the application but I cannot see how to get it to shut it down properly. I've got it to simply kill the process by setting the deactivation-timeout to 1 second but I'd like to get the shutdown working correctly.

From what I can gather I can somehow use the Ice::Process facet to do this. I don't want to use the Ice::Application functionality as it doesn't fit with what we already have in place.

Can someone give me some example code on how to use this mechanism as the docs don't seem to explain much at all in this regard.

Mark.

Comments

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Mark,

    If you deploy your application (server) with IceGrid, IceGrid generates the server's configuration for you, and this configuration contains all the necessary "Ice Admin" setup. Basically, you don't need to do anything.

    It could be that this Ice Admin facet is created and called by IceGrid, but that your application does not shutdown properly as a result.

    When IceGrid "shuts down" a process through this Ice Admin facet, your Ice communicator is shut down. You could detect this shutdown if you have a thread blocked on communicator->waitForShutdown() and properly terminate you server when this call returns.

    Best regards
    Bernard
  • marksnellingmarksnelling Member Mark SnellingOrganization: Winton Capital ManagementProject: Trading System
    That's strange. I have deployed this using IceGrid but when I use icegridadmin to shutdown the application nothing happens. This is why I used the timeout to simply terminate the app.

    I don't have a thread waiting on the communicator to shutdown and would rather not.

    Is there another way to capture this event?
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Mark,

    There is also a Communicator::isShutdown operation that you could call from time to time.

    However, the cleanest solution is to implement your own "Process" facet, possibly reusing the Ice-provided Process facet implementation.

    You just need to:
    - remove the old facet with communicator->removeAdminFacet("Process");
    - install your own Ice::Process servant (facet) with communicator->addAdminFacet(servant, "Process");

    Don't forget to shutdown your Ice communicator in Process::shutdown.

    Best regards,
    Bernard
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Mark,

    With the solution I outlined in my previous post, there is a potential race condition: you start your server and before you have time to replace the Process facet, somebody calls shutdown on the old facet (through IceGrid).

    Fortunately there is a solution: you can delay the creation of the Admin object until after all your facets are setup properly.

    Just set Ice.Admin.DelayCreation to 1 in your configuration, and call communicator->getAdmin() in your code when all your Admin facets are ready (getAdmin creates the Admin object).

    Cheers,
    Bernard
  • marksnellingmarksnelling Member Mark SnellingOrganization: Winton Capital ManagementProject: Trading System
    Thanks Bernard, that worked well.

    Mark.
Sign In or Register to comment.