Commit 9367d6cda6f9ad3a4e9a6779543cbc35ee5376d5
1 parent
df4341dc
KTS-2525
"Create windows service to wrap around scheduler" Updated. Fixed issues executing cross platform. Committed By: Kevin Fourie Reviewed By: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7509 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
26 additions
and
7 deletions
bin/win32/schedulerService.php
| ... | ... | @@ -6,6 +6,20 @@ $myservicename = 'ktscheduler'; |
| 6 | 6 | if (!win32_start_service_ctrl_dispatcher($myservicename)) die('Could not connect to service :'.$myservicename); |
| 7 | 7 | win32_set_service_status(WIN32_SERVICE_RUNNING); |
| 8 | 8 | |
| 9 | +require_once('../../config/dmsDefaults.php'); | |
| 10 | + | |
| 11 | +global $default; | |
| 12 | + | |
| 13 | +$config = KTConfig::getSingleton(); | |
| 14 | +$schedulerInterval = $config->get('KnowledgeTree/schedulerInterval',10); // interval in seconds | |
| 15 | +$phpPath = $config->get('externalBinary/php','php'); | |
| 16 | + | |
| 17 | +if (!is_file($phpPath)) | |
| 18 | +{ | |
| 19 | + $default->log->error("Scheduler: php not found: $phpPath"); | |
| 20 | + exit; | |
| 21 | +} | |
| 22 | + | |
| 9 | 23 | // Main Scheduler Service Loop |
| 10 | 24 | while (1) { |
| 11 | 25 | |
| ... | ... | @@ -23,15 +37,20 @@ while (1) { |
| 23 | 37 | |
| 24 | 38 | // Setup php binary path |
| 25 | 39 | $phpPath = realpath('../../php/php.exe'); |
| 26 | - if (!is_file($phpPath)) | |
| 27 | - { | |
| 28 | - die('Cannot find php.exe'); | |
| 29 | - } | |
| 30 | - | |
| 40 | + | |
| 41 | + | |
| 31 | 42 | // Run the scheduler script |
| 32 | - system("$phpPath scheduler.php"); | |
| 33 | 43 | |
| 34 | - sleep(10); // Run every 10 seconds | |
| 44 | + $cmd = "\"$phpPath\" scheduler.php"; | |
| 45 | + | |
| 46 | + $cmd = str_replace( '/','\\',$cmd); | |
| 47 | + $res = `"$cmd" 2>&1`; | |
| 48 | + if (!empty($res)) | |
| 49 | + { | |
| 50 | + $default->log->error('Scheduler: unexpected output - ' .$res); | |
| 51 | + } | |
| 52 | + | |
| 53 | + sleep($schedulerInterval); | |
| 35 | 54 | |
| 36 | 55 | } |
| 37 | 56 | win32_set_service_status(WIN32_SERVICE_STOPPED); | ... | ... |