Jump to content

How to create a windows service in PHP


sunilvadranapu

Recommended Posts

My script need to be run when i START windows service from SCM(service Control Mangaer). Like a deamon in Linux. I want proceduer for creating a windows service.

Actually i created the windows service using win32_create_service(). But when i start the windows service Status was not changed in SCM. Hot to change the status using win32_set_service_status().

 

I have created a windows service as

<?php

if ($argv[1] == 'install') {

$x = win32_create_service(array(

'service' => 'dummyphp',

'display' => 'PHPservice',

'path' => 'C:\php\php.exe',

'params' => 'C:\trickle.php  source=/sdfs601/tetools/xmlloader/xmlcentral instance=demo dbname=sateesh dbuser=sateesh dbpass=sateesh keepfiles=true logging=hour debug=true' . ' run',

));

debug_zval_dump($x);

exit;

} else if ($argv[1] == 'uninstall') {

$x = win32_delete_service('dummyphp');

debug_zval_dump($x);

exit;

} else if ($argv[1] != 'run') {

//die("bogus args");

}

 

if (!win32_start_service_ctrl_dispatcher('dummyphp')) {

  die("I'm probably not running under the service control manager");

}

else

  echo "Registered with SCM";

 

while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {

usleep(250000);

}

 

?>

 

where to write the code to chnage the status to START in SCM??

 

Thanks

SunilKumar

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.