/[drupal]/contributions/modules/transformer/transformer_daemon.php
ViewVC logotype

Contents of /contributions/modules/transformer/transformer_daemon.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Mar 7 10:04:29 2007 UTC (2 years, 8 months ago) by dopry
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -1 lines
File MIME type: text/x-php
iadd tiny comment.
1 <?php
2 // $Id: transformer_daemon.php,v 1.1 2007/03/07 10:02:18 dopry Exp $
3
4 /**
5 * @file
6 *
7 * a sample transformer daemon.
8 * big fat warning this should be considered psuedo code only at the moment.
9 *
10 * @todo update to support concurrent queue runners.
11 *
12 */
13
14 //ini_set out the mem and time limits.
15 //include('path/to/boostrap.inc');
16 include('../../../../includes/bootstrap.inc');
17 drupal_bootstrap(BOOTSTRAP_DATABASE);
18 module_enable('transformer');
19
20
21
22 // @todo: command line args for priority and sleep.
23 $priority = 9;
24 $sleep = 1000;
25
26 // main loop.
27 while(TRUE) {
28 // get next macro to process.
29 $result = db_query('SELECT * FROM {transformer_queue} WHERE priority < %d LIMIT 0,1', $priority);
30 $job = db_fetch_object($result);
31 $macro = transformer_macro($job->macro_id);
32 if (transformer_macro_perform($macro, $job->src, $job->dst, $priority)) {
33 db_query("DELETE FROM {tranformer_queue} WHERE transformer_queue_id = %d", $job->transformer_queue_id);
34 }
35 else {
36 // watchdog job failed message.
37
38 // move to end of queue on failure to prevent queue from clogging.
39 $new_id = db_next_id('transformer_queue');
40 db_query("UPDATE {tranformer_queue} SET transformer_queue_id = %d WHERE transformer_queue_id = %d", $new_id, $job->transformer_queue_id);
41 }
42 // rest for sec... we might as well give the server a few ticks to catch its breath, empty swap, play a video
43 // game, etc.
44 sleep($sleep);
45
46 }

  ViewVC Help
Powered by ViewVC 1.1.2