How to keep a service running?

Author: martinandheather@gmail.com (byjones)

I have an application which starts a userver process on a server to run every minute (using utimer to control this).

However, when my 'launcher' application quits, I need this service to keep running every minute.

Currently, as soon as it quits, the service goes through the Cleanup operation and no longer runs.

The service is set as Self Contained and Detached.

How can I make this service continue functioning?

Ideally, I want to be able to stop/start it running from my client, but then leave it functioning behind the scenes, and re-launch my client to monitor it if required. If the server reboots for whatever reason, upon reboot, I want my service to continue in whatever state it was prior to the reboot, without the need to login to the server to manually start this process (I think I can achieve this with a batch file to run on system startup).

Any thoughts?

Martin

6 Comments

  1. Hi

    I can't tell you exactly how to do such a thing, because of the monitoring and the automatic database connexion, but the solution to keep a service running, detached from the client, is to run it asynchronously (/async).

    We've use this for our interoperability module (which is by nature detached from any client), and it works quit well since 2000. But the key point is to monitor correctly those asynchronous services, to be able to stop or restart them.

    Best regards,
    Richard


    Author: richard.gill (richard.gill@agfa.com)
  2. We have the same functionnality.

    Our implementation is :

    On Windows :

    - Create a service

       Command : uniface.exe /asn=... /ini=... Startupshell myService

       You must specify all variables for your service (PATH,...)

       Those informations are in the registry

    - Launch service

    - Create a schedule task who check each minutes if the process uniface.exe of the user UserWhoLaunchService

        If the number of process doen't correct, stop service, move log ($putmess_logfile) start service

    On Unix

      We must think about the implementation, because, it's our future target.

    Regards.


    Author: apicaud (antoine.picaud@free.fr)
  3. Running a service using uniface.exe will have the 'bad' habit of using up a user licence for that service.


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  4. I tried a number of things, and in the end, exposed my service component as a web service (was using web services anyway, so not a big deal).

    I then wrote a windows service in .NET and use this to call the operation in my web service every minute. The service is set to Automatic start, so this should take care of the rebooting issue.

    Thanks for the tips.

    Martin


    Author: byjones (martinandheather@gmail.com)
  5. Great that you have a solution.

    Maybe take a look at the urouter monitor API. I've used this in combination with post message to achieve what you are after. It is similar to using regular /asyn activation, however this technique can open numerous other possibilities too.

     

     


    Author: Jason Huggins (jason.huggins@uniface.com)
  6. Hi

    Have you more materials for this usage of the monitor API with postmessage ? I'm interested, but the first time I tried, the API crashed while getting the client list, and I'm not sure about the postmessage thing : you mean the messageing API or the proc postmessage (which really is a sendmessage) ?

    Best Regards,
    Richard


    Author: richard.gill (richard.gill@agfa.com)