-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadminActions.php
47 lines (40 loc) · 1.36 KB
/
adminActions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* This file is part of Win32Service Library package
* @copy Win32Service (c) 2018-2019
* @author "MacintoshPlus" <macintoshplus@mactronique.fr>
*/
use Win32Service\Model\ServiceInformations;
use Win32Service\Model\ServiceIdentifier;
use Win32Service\Service\ServiceAdminManager;
include __DIR__.'/../vendor/autoload.php';
//Init the service informations
$serviceInfos = new ServiceInformations(
ServiceIdentifier::identify('my_test_service', 'localhost'),
'PHP service for tests',
'This service does not compute anything, just prove the concept.',
__DIR__.DIRECTORY_SEPARATOR.'service.php',
''
);
if (!isset($argv[1]) || ($argv[1] !== 'register' && $argv[1] !== 'unregister')) {
die("Usage ".$argv[0]." register|unregister\n");
}
$adminService = new ServiceAdminManager();
//Register the service
if ($argv[1] === 'register') {
try {
$adminService->registerService($serviceInfos);
echo 'Registration success';
} catch(Exception $e) {
echo 'Error : ('.$e->getCode().') '.$e->getMessage()."\n";
}
}
//Unregister the service
if ($argv[1] === 'unregister') {
try {
$adminService->unregisterService($serviceInfos);
echo 'Unregistration success';
} catch(Exception $e) {
echo 'Error : ('.$e->getCode().') '.$e->getMessage()."\n";
}
}