Web Connection
Background Cleanup program on Server
Gravatar is a globally recognized avatar based on your email address. Background Cleanup program on Server
  Joel Aiken
  All
  Jun 3, 2019 @ 06:07am

I am running a "background cleanup" program on a web server. The purpose of the cleanup program is to:

  1. PACK MEMO on several tables
  2. run API requests to gather data from an online web store.
  3. Delete old records from dbfs that grow too large
  4. Run some reports and email them out.

I'm concerned that the background prg will collide with users' web requests. In fact, I'm pretty sure I'm seeing this happen when errors occur.

I'm asking your advice on the best way to avoid collisions. It occurs to me that I could issue an IIS STOP command, then run the Background prg, then IIS START. I'm wondering if there are better solutions.

I also am considering running the background prg as a web request itself. But I'm not sure how to run a URL from a prg. Pardon me if I'm overlooking an obvious technique.

Joel Aiken

Gravatar is a globally recognized avatar based on your email address. re: Background Cleanup program on Server
  Rick Strahl
  Joel Aiken
  Jun 3, 2019 @ 05:05pm

Running it as a Web Request is probably the cleaner way if that's possible. But you do need to put the server into a 'single server' mode.

You can use wwHttp to do this:

  • Single Server mode URL: https://yoursite.com/LoadOneComServer.wc (have to be authenticated)
  • Then run your request: https://yoursite.com/DoMyFileCleanup.map (should be authenticated)
  • Load servers normall: https://yoursite.com/LoadComServers.wc

You can load all of these URLs via wwHttp from a PRG assuming hte server is running. You probably should check along the way and make sure each request worked (check for specific values in the strings).

This is essentially what bld_YourApp.prg with .T. does except it shuts down the server, hot swaps a file, then restarts the servers. In your case instead of putting the server in hold request mode, you use the urls above. Same idea.

You can check your bld_YourApp.prg to see how that all works or if your project predates that just create a new project and look at that file to give you a starting point (just the HTTP server request bits).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Background Cleanup program on Server
  Joel Aiken
  Rick Strahl
  Jun 3, 2019 @ 06:40pm

Rick, Thanks. Sounds like perfect advice for me to work with. I'll report back how it works out for me. Joel

© 1996-2019