2 $options = getopt('bc:ht:');
3 if (isset($options['h'])) {
4 print ("\nUsage: php civimail-spooler.php [-bh] [-c <config>] [-t <period>]\n");
5 print (" -b Run this process continuously\n");
6 print (" -c Path to CiviCRM civicrm.settings.php\n");
7 print (" -h Print this help message\n");
8 print (" -t In continuous mode, the period (in seconds) to wait between queue events\n\n");
12 if (isset($options['c'])) {
13 $config_file = $options['c'];
17 require_once "$config_file";
18 require_once "CRM/Core/Config.php";
21 $config = CRM_Core_Config
::singleton();
23 /* Temporary permissioning hack for now */
26 CRM_Utils_System_Soap
::swapUF();
28 if (isset($options['t']) && is_int($options['t']) && $options['t'] > 0) {
29 $config->mailerPeriod
= $options['t'];
32 if (isset($options['b'])) {
34 /* TODO: put some syslog calls in here. Also, we may want to fork the
35 * process into the background and provide init.d scripts */
38 CRM_Mailing_BAO_MailingJob
::runJobs();
39 sleep($config->mailerPeriod
);
43 CRM_Mailing_BAO_MailingJob
::runJobs();