Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Limited Processes Problem

Options
  • 03-08-2000 4:43am
    #1
    Closed Accounts Posts: 202 ✭✭


    Here's the situation:
    I'm building a web application that needs to have a background process that counts down over a period of a week or so and triggers an event when it reaches zero.

    The problem:
    The server the site is situated on limits users to one process only. One process that is already taken up by MySQL.

    There are two possible solutions that I can come up with, neither of which I'm very happy with.

    Suggested Solution One:
    The site is fairly heavily hit (16-18,000 hits a day) so maybe I could put an invisible frame at the bottom of the site that contains a cgi script that checks the clock and refreshes after 60 seconds or so. As long as there's someone looking at the page then the countdown is running.

    Suggested Solution Two (preffered):
    Maybe I could write a little Perl script that forks into two, running safe_mysqld and my countdown_d script. But that would probably count as two processes.

    Has anyone here got any opinions or ideas?

    Thanks



Comments

  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    Your second solution will count as 2 processes if you're intending to use perl's fork()

    Is it possible to maintain a value in your database and use your web scripts to check for time elapsed and update it accordingly? (assuming it is a specific period of time you want to elapse)

    Also, you say you are restricted to one process, which is your mysqld. However, the web scripts must be running under a uid, most likely the webserver user if that is the case, and who is most likely not restricted, so you could probably use a fork() call from a cgi script and not have it count as one of your processes (may not be suitable if your event requires your privileges of course, but I don't see how you get to have any events with your mysql running wink.gif )


  • Closed Accounts Posts: 202 ✭✭Karla


    Cheers, I think I'll go with solution 1 after all.
    All CGI scripts on the server are actually run as the owner, not 'nobody' or 'httpd' or whatever. So that means I wouldn't be able to write a CGI to fork(). Good thinking though! smile.gif

    I guess the first option is the easiest and is actually guaranteed to work too. If no one looks at the site until after the countdown reaches zero then it'll just trigger the even when they do arrive.

    Cheers



Advertisement