How to control background processes from inside Drupal?
Hello there, Is there any way to start/stop background processes from inside Drupal? I'm currently writing a module that has to continuously monitor a socket connection for events coming from a remote server. I thought about using hook_cron(), but I'm afraid that the infinite (or continuous) loop of my event handler would tie out other modules that use hook_cron(). Another alternative would be to use batch api, but do batch processes run in the background? Thanks in advance, Leo
Yes, you can excute any command using php. On Mon, May 10, 2010 at 9:02 PM, Leo Burd <leob@media.mit.edu> wrote:
Hello there,
Is there any way to start/stop background processes from inside Drupal?
I'm currently writing a module that has to continuously monitor a socket connection for events coming from a remote server. I thought about using hook_cron(), but I'm afraid that the infinite (or continuous) loop of my event handler would tie out other modules that use hook_cron(). Another alternative would be to use batch api, but do batch processes run in the background?
Thanks in advance,
Leo
-- A decathlon Drupal developer & programmer http://blog.eood.cn/
You might want to think about queue, which has been backported to D6. Here are rough notes from John VanDyk's drupalcon sf preso on batch v. queue: // when to use batch: - when you're doing something that will exceed php's time-out - when you're writing something that could get large - when you want to give users feedback on what's going on when to use queue - when you want to stash things for later processing - when you want to distribute computing - when you want to run queue "with a twist" (conditional outputs, other processes kicked off, etc) // ...not that those were particularly useful to your question, but they're a basis. There are some details instructions in drupal_queue.module's readme.txt (the backport from D7) that will help you decide whether running a queue under a separate crontab (or even using drush) makes sense. If I were in your position, I'd lean heavily in that direction not only for the "offswitch", but for the option of distributing that computing down the road, which is possible with queue. regards/BF On Mon, May 10, 2010 at 9:02 AM, Leo Burd <leob@media.mit.edu> wrote:
Hello there,
Is there any way to start/stop background processes from inside Drupal?
I'm currently writing a module that has to continuously monitor a socket connection for events coming from a remote server. I thought about using hook_cron(), but I'm afraid that the infinite (or continuous) loop of my event handler would tie out other modules that use hook_cron(). Another alternative would be to use batch api, but do batch processes run in the background?
Thanks in advance,
Leo
On Mon, May 10, 2010 at 1:02 PM, Leo Burd <leob@media.mit.edu> wrote:
Is there any way to start/stop background processes from inside Drupal?
An alternative solution is to write a lightweight php file that runs via command-line php and can write to the Drupal database. You start off your file with <?php require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); And then you have full access to the Drupal environment including db_query to be able to read/write information in the Drupal environment. Regards, Greg -- Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com Mastering Drupal | http://www.masteringdrupal.com
I always use this script for debug. :) On Mon, May 10, 2010 at 11:08 PM, Greg Knaddison <Greg@growingventuresolutions.com> wrote:
On Mon, May 10, 2010 at 1:02 PM, Leo Burd <leob@media.mit.edu> wrote:
Is there any way to start/stop background processes from inside Drupal?
An alternative solution is to write a lightweight php file that runs via command-line php and can write to the Drupal database.
You start off your file with
<?php require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
And then you have full access to the Drupal environment including db_query to be able to read/write information in the Drupal environment.
Regards, Greg
-- Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com Mastering Drupal | http://www.masteringdrupal.com
-- A decathlon Drupal developer & programmer http://blog.eood.cn/
I don't have any experience in this realm, but you might look at http://drupal.org/project/daemon or http://drupal.org/project/daemoncli On Mon, May 10, 2010 at 9:02 AM, Leo Burd <leob@media.mit.edu> wrote:
Hello there,
Is there any way to start/stop background processes from inside Drupal?
I'm currently writing a module that has to continuously monitor a socket connection for events coming from a remote server. I thought about using hook_cron(), but I'm afraid that the infinite (or continuous) loop of my event handler would tie out other modules that use hook_cron(). Another alternative would be to use batch api, but do batch processes run in the background?
Thanks in advance,
Leo
participants (5)
-
Brian Fending -
Greg Knaddison -
icerain -
Leo Burd -
Moshe Weitzman