NetTalk Central

Author Topic: Halting a WebServer program from an external process  (Read 3353 times)

GordonF

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Halting a WebServer program from an external process
« on: May 20, 2021, 03:40:41 AM »
I have a question relating to the client software upgrade process.

During client system upgrades there is a requirement to close any running applications, perform the upgrade and then relaunch any applications that were stopped.

For years I have used an ini file to control requests to suspend and then restart, basically I have a suspend, a start and a control app for each background application in the suite, by using these I get reliable and graceful control over upgrades. However, it is something I have used for many years and I'm sure that there may be a better method of achieving inter-application communications, maybe using built-in Windows events, so feel free to enlighten me, perhaps WinEvent already provides this facility.

Now to the point, I have only recently added a WebServer application to the suite and it is working fine, but I do have one concern and perhaps Bruce is best placed to answer this question. By default I have a 1 second timer on the application's main Window (WebServer), each second I check an ini for a suspend request, if found the application closes gracefully. My concern is the effect a 1 second timer will have when running on the main WebServer window. The alternative is to launch a timer process on a separate thread and pass a user defined event or a notify back to the webserver window to instruct it to close down.

Any suggestions welcome, how do others close a webserver for software upgrades, there are too many clients to do this manually.

Gordon

Jane

  • Sr. Member
  • ****
  • Posts: 372
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Halting a WebServer program from an external process
« Reply #1 on: May 20, 2021, 06:57:08 AM »
I've also used the INI trick for a number of desktop apps over the years.  In those, I've had it display a 5 minute and 2 minute warning before pulling the plug altogether.

I don't see any reason that your second thread idea wouldn't work.  (Obviously you'd need to kill that thread yourself as well as posting the shutdown instruction to the web server procedure.)

But I think I'd consider adding an "admin" API and calling that to initiate the shutdown.  Assuming your upgrade process could figure out a way to post the shutdown command to it.

Or you could build a helper app that monitors your shutdown INI and uses OddJob to kill the web server process.

If your web server is running as a service, you could script a "Stop Service" command in a SetupBuilder setup program.

Jane

GordonF

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Halting a WebServer program from an external process
« Reply #2 on: May 20, 2021, 07:23:44 AM »
Thank you Jane, you've given me food for thought.

Cheers
Gordon
« Last Edit: May 20, 2021, 07:38:33 AM by GordonF »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Halting a WebServer program from an external process
« Reply #3 on: May 20, 2021, 08:21:36 PM »
I'd slow the timer down, 1 second is likely overkill, 5 seconds should be fine.
But reading an INI file every 5 seconds (or even every second) will have no impact on server performance.

Cheers
Bruce

GordonF

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Halting a WebServer program from an external process
« Reply #4 on: May 20, 2021, 11:11:15 PM »
Thanks Bruce, I'll do that.

Gordon