forked from nospaceships/node-os-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
115 lines (101 loc) · 4.33 KB
/
index.d.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* Options for the add() function.
*/
export interface AddOptions {
/**
* The services display name, defaults to the name parameter. T
* his parameter will be used on Windows platforms only
*/
displayName?: string;
/**
* The command used to run the service
* (i.e. c:\Program Files\nodejs\node.exe, defaults to the value of process.execPath
*/
command?: string;
/**
* An array of strings specifying parameters to pass to command, defaults to []
*/
args?: string[];
/**
* An array of strings specifying other services this service depends on, this is optional
*/
dependencies?: string[];
/**
* For Windows platforms a username and password can be specified,
* the service will be run using these credentials when started,
* see the CreateService() functions win32 API documentation for
* details on the format of the username, on all other platforms this parameter is ignored
*/
username?: string;
/**
* See the username parameter
*/
password?: string;
/**
* An array of numbers specifying Linux run-levels at which the service should be started
* for Linux platforms, defaults to [2, 3, 4, 5], this is only used when chkconfig or
* update-rc.d is used to install a service
*/
runLevels?: number[];
/**
* For when systemd will be used a target can be specified for the WantedBy
* attribute under the [Install] section in the generated systemd unit file,
* defaults to multi-user.target
*/
systemdWantedBy?: string;
}
/**
* The add() function adds a service.
* @param name Specifies the name of the created service.
* @param opts Additional options.
* @param callback Is called once the service has been added. The following
* arguments will be passed to the callback function:
* error - Instance of the Error class, or null if no error occurred
*/
export function add(name: string, opts: AddOptions, callback: (error?: Error) => void): void;
export function add(name: string, callback?: (error?: Error) => void): void;
/**
* The remove() function removes a service.
* The service must be in a stopped state for it to be removed.
* @param name Specifies the name of the service to remove.
* This will be the same name parameter specified when adding the service.
* @param callback Is called once the service has been removed. The following
* arguments will be passed to the callback function:
* error - Instance of the Error class, or null if no error occurred
*/
export function remove(name: string, callback: (error?: Error) => void): void;
/**
* The enable() function enable a service.
* The service must be in a stopped state for it to be enabled.
* @param name Specifies the name of the service to enable.
* This will be the same name parameter specified when adding the service.
* @param callback Is called once the service has been enabled. The following
* arguments will be passed to the callback function:
* error - Instance of the Error class, or null if no error occurred
*/
export function enable(name: string, callback: (error?: Error) => void): void;
/**
* The disable() function disable a service.
* The service must be in a running state for it to be disabled.
* @param name Specifies the name of the service to disable.
* This will be the same name parameter specified when adding the service.
* @param callback Is called once the service has been disabled. The following
* arguments will be passed to the callback function:
* error - Instance of the Error class, or null if no error occurred
*/
export function disable(name: string, callback: (error?: Error) => void): void;
/**
* The run() function will attempt to run the program as a service.
* @param stopCallback Will be called when the service receives a stop request,
* e.g. because the Windows Service Controller was used to send a stop request to the service,
* or a SIGTERM signal was received.
*/
export function run(stopCallback: () => void): void;
/**
* The stop() function will cause the service to stop, and the calling program to exit.
* Once the service has been stopped this function will terminate the program by calling
* the process.exit() function, passing to it the rcode parameter which defaults to 0.
* Before calling this function ensure the program has finished performing cleanup tasks.
* @param rcode Return code defaults to 0
*/
export function stop(rcode?: number): void;