Merge pull request #1167 from colemanw/getOptionLabels
[civicrm-core.git] / tools / scripts / civimail-spooler / civimail-spooler.php
CommitLineData
6a488035
TO
1<?php
2$options = getopt('bc:ht:'); if (isset($options['h'])) {
3 print ("\nUsage: php civimail-spooler.php [-bh] [-c <config>] [-t <period>]\n");
4 print (" -b Run this process continuously\n");
5 print (" -c Path to CiviCRM civicrm.settings.php\n");
6 print (" -h Print this help message\n");
7 print (" -t In continuous mode, the period (in seconds) to wait between queue events\n\n");
8 exit();
9}
10
11if (isset($options['c'])) {
12 $config_file = $options['c'];
13}
14
15eval('
16require_once "$config_file";
17require_once "CRM/Core/Config.php";
18');
19
20$config = &CRM_Core_Config::singleton();
21
22/* Temporary permissioning hack for now */
23
24
25CRM_Utils_System_Soap::swapUF();
26
27if (isset($options['t']) && is_int($options['t']) && $options['t'] > 0) {
28 $config->mailerPeriod = $options['t'];
29}
30
31if (isset($options['b'])) {
32 while (TRUE) {
33 /* TODO: put some syslog calls in here. Also, we may want to fork the
34 * process into the background and provide init.d scripts */
35
36
37
9da8dc8c 38 CRM_Mailing_BAO_MailingJob::runJobs();
6a488035
TO
39 sleep($config->mailerPeriod);
40 }
41}
42else {
9da8dc8c 43 CRM_Mailing_BAO_MailingJob::runJobs();
6a488035
TO
44}
45