Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I would make the CGI create a new process for the long operation. Write the PID of the new process to a place where a later CGI call can find it (i.e. database). Use some kind of IPC to ask the long-running process for its status, to abort it, and so on. OLE could work, or local TCP or UDP sockets. But this may be a little bit too simple, because it does not take the system load into account.

Another way would be a permanently running daemon / Windows service. That service has to implement an IPC interface (OLE, local TCP or UDP sockets). The CGI is just managing that service; when a new long job has to start, it just tells the service to start the job. The service decides when and how to start the job.

Robustness w.r.t system restarts as you describe it is not too hard with the service way, as services can be set to auto-start. If you mean that jobs aborted due to the reboot have to be restarted, you need to track the job statuses in the service.

If you want to delay the startup until the webserver runs, the web server has to notify the long job service. mod_perl offers a startup hook that could do this.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Handling long running operations started by CGI requests by afoken
in thread Handling long running operations started by CGI requests by oyse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found