示例#1
0
 public function install()
 {
     Settings::$path = escapeshellarg(Settings::$path);
     $this->action(function () {
         cmd::echoL1('Installing service: ' . Settings::$service . ' ' . Settings::$params . PHP_EOL);
         if (Settings::$svc_type != ServiceTypeBitmasks::OWN) {
             Settings::$path = escapeshellcmd(Settings::$path);
             Settings::$params = escapeshellcmd(Settings::$params);
         }
         return win32_create_service(Settings::toArray());
     });
 }
示例#2
0
<?php

namespace Albus\Win32Service;

use Albus\CMD\SC;
use Albus\Win32Service\Win32Constants\ServiceStatusConstants;
switch (PHP_SAPI) {
    case !'cli':
        break;
    default:
        Settings::getCLIparams();
        win32_start_service_ctrl_dispatcher(Settings::$service);
        register_shutdown_function(function () {
            win32_set_service_status(ServiceStatusConstants::STOPPED);
        });
        SC::$onFailtureRun = 5000;
        SC::$onFailtureRestart = 3000;
        SC::$msFailterCountReset = 5000;
        echo 'Start action: ' . Settings::$action . PHP_EOL;
        Settings::$params = urldecode(http_build_query(['-f' => escapeshellarg(Settings::$ScriptPathName), '-- --action' => escapeshellarg('run'), '--service' => escapeshellarg(Settings::$service)], null, ' '));
        call_user_method(Settings::$action, new Deamon());
        register_shutdown_function(function () {
            echo 'Stop action: ' . Settings::$action . PHP_EOL;
        });
}