![]() |
Bearsampp 2025.8.29
|
Public Member Functions | |
__construct ($name) | |
create () | |
delete () | |
getBinPath () | |
getDisplayName () | |
getEnvironmentExtra () | |
getError () | |
getLatestError () | |
getLatestStatus () | |
getName () | |
getParams () | |
getStart () | |
getStderr () | |
getStdout () | |
infos () | |
isInstalled () | |
isPaused () | |
isPending ($status) | |
isRunning () | |
isStopped () | |
restart () | |
setBinPath ($binPath) | |
setDisplayName ($displayName) | |
setEnvironmentExtra ($environmentExtra) | |
setName ($name) | |
setParams ($params) | |
setStart ($start) | |
setStderr ($stderr) | |
setStdout ($stdout) | |
start () | |
status ($timeout=true) | |
stop () |
Data Fields | |
const | INFO_APP_DIRECTORY = 'AppDirectory' |
const | INFO_APP_ENVIRONMENT_EXTRA = 'AppEnvironmentExtra' |
const | INFO_APP_PARAMETERS = 'AppParameters' |
const | INFO_APP_STDERR = 'AppStderr' |
const | INFO_APP_STDOUT = 'AppStdout' |
const | INFO_APPLICATION = 'Application' |
const | PENDING_TIMEOUT = 10 |
const | SERVICE_AUTO_START = 'SERVICE_AUTO_START' |
const | SERVICE_DELAYED_START = 'SERVICE_DELAYED_START' |
const | SERVICE_DEMAND_START = 'SERVICE_DEMAND_START' |
const | SERVICE_DISABLED = 'SERVICE_DISABLED' |
const | SERVICE_INTERACTIVE_PROCESS = 'SERVICE_INTERACTIVE_PROCESS' |
const | SERVICE_WIN32_OWN_PROCESS = 'SERVICE_WIN32_OWN_PROCESS' |
const | SLEEP_TIME = 500000 |
const | STATUS_CONTINUE_PENDING = 'SERVICE_CONTINUE_PENDING' |
const | STATUS_NA = '-1' |
const | STATUS_NOT_EXIST = 'SERVICE_NOT_EXIST' |
const | STATUS_PAUSE_PENDING = 'SERVICE_PAUSE_PENDING' |
const | STATUS_PAUSED = 'SERVICE_PAUSED' |
const | STATUS_RUNNING = 'SERVICE_RUNNING' |
const | STATUS_START_PENDING = 'SERVICE_START_PENDING' |
const | STATUS_STOP_PENDING = 'SERVICE_STOP_PENDING' |
const | STATUS_STOPPED = 'SERVICE_STOPPED' |
Private Member Functions | |
exec ($args) | |
getServiceStatusDesc ($status) | |
writeLog ($log) | |
writeLogError ($log) | |
writeLogInfo ($log) |
Private Attributes | |
$binPath | |
$displayName | |
$environmentExtra | |
$latestError | |
$latestStatus | |
$name | |
$params | |
$start | |
$stderr | |
$stdout |
Class Nssm
This class provides methods to manage Windows services using NSSM (Non-Sucking Service Manager). It includes functionalities to create, delete, start, stop, and retrieve the status of services. The class also logs operations and errors.
Definition at line 17 of file class.nssm.php.
__construct | ( | $name | ) |
Nssm constructor. Initializes the Nssm class and logs the initialization.
string | $name | The name of the service. |
Definition at line 68 of file class.nssm.php.
References $name, and Util\logInitClass().
create | ( | ) |
Creates a new service.
Definition at line 183 of file class.nssm.php.
References exec(), getBinPath(), getDisplayName(), getEnvironmentExtra(), getName(), getParams(), getStart(), getStderr(), getStdout(), isInstalled(), and writeLog().
delete | ( | ) |
Deletes the service.
Definition at line 264 of file class.nssm.php.
References exec(), getName(), isInstalled(), stop(), and writeLog().
|
private |
Executes an NSSM command.
string | $args | The arguments for the NSSM command. |
Definition at line 114 of file class.nssm.php.
References $bearsamppCore, $result, Batch\exec(), and writeLogInfo().
Referenced by create(), delete(), start(), status(), and stop().
getBinPath | ( | ) |
Gets the binary path of the service.
Definition at line 538 of file class.nssm.php.
References $binPath.
Referenced by create().
getDisplayName | ( | ) |
Gets the display name of the service.
Definition at line 518 of file class.nssm.php.
References $displayName.
Referenced by create().
getEnvironmentExtra | ( | ) |
Gets the additional environment variables for the service.
Definition at line 638 of file class.nssm.php.
References $environmentExtra.
Referenced by create().
getError | ( | ) |
Retrieves the error message or status description of the service.
Definition at line 678 of file class.nssm.php.
References $bearsamppLang, $latestError, Lang\ERROR, and Lang\STATUS.
getLatestError | ( | ) |
Gets the latest error message related to the service.
Definition at line 668 of file class.nssm.php.
References $latestError.
getLatestStatus | ( | ) |
Gets the latest status of the service.
Definition at line 658 of file class.nssm.php.
References $latestStatus.
getName | ( | ) |
Gets the name of the service.
Definition at line 498 of file class.nssm.php.
References $name.
Referenced by create(), delete(), infos(), isInstalled(), isPaused(), isRunning(), isStopped(), start(), status(), and stop().
getParams | ( | ) |
Gets the parameters of the service.
Definition at line 558 of file class.nssm.php.
References $params.
Referenced by create().
|
private |
Retrieves the description of the service status.
string | $status | The status to describe. |
Definition at line 461 of file class.nssm.php.
getStart | ( | ) |
Gets the start type of the service.
Definition at line 578 of file class.nssm.php.
References $start.
Referenced by create().
getStderr | ( | ) |
Gets the stderr path of the service.
Definition at line 618 of file class.nssm.php.
References $stderr.
Referenced by create().
getStdout | ( | ) |
Gets the stdout path of the service.
Definition at line 598 of file class.nssm.php.
References $stdout.
Referenced by create().
infos | ( | ) |
Retrieves information about the service.
Definition at line 348 of file class.nssm.php.
References getName(), Vbs\getServiceInfos(), Registry\HKEY_LOCAL_MACHINE, INFO_APP_PARAMETERS, INFO_APPLICATION, and Win32Service\VBS_PATH_NAME.
isInstalled | ( | ) |
Checks if the service is installed.
Definition at line 394 of file class.nssm.php.
References getName(), status(), and writeLog().
isPaused | ( | ) |
Checks if the service is paused.
Definition at line 433 of file class.nssm.php.
References getName(), status(), and writeLog().
isPending | ( | $status | ) |
Checks if the service status is pending.
string | $status | The status to check. |
Definition at line 448 of file class.nssm.php.
Referenced by status().
isRunning | ( | ) |
Checks if the service is running.
Definition at line 407 of file class.nssm.php.
References getName(), status(), and writeLog().
Referenced by start().
isStopped | ( | ) |
Checks if the service is stopped.
Definition at line 420 of file class.nssm.php.
References getName(), status(), and writeLog().
Referenced by stop().
restart | ( | ) |
Restarts the service.
Definition at line 334 of file class.nssm.php.
setBinPath | ( | $binPath | ) |
Sets the binary path of the service.
string | $binPath | The binary path to set. |
Definition at line 548 of file class.nssm.php.
References $binPath, and Util\formatWindowsPath().
setDisplayName | ( | $displayName | ) |
Sets the display name of the service.
string | $displayName | The display name to set. |
Definition at line 528 of file class.nssm.php.
References $displayName.
setEnvironmentExtra | ( | $environmentExtra | ) |
Sets the additional environment variables for the service.
string | $environmentExtra | The additional environment variables to set. |
Definition at line 648 of file class.nssm.php.
References $environmentExtra, and Util\formatWindowsPath().
setName | ( | $name | ) |
Sets the name of the service.
string | $name | The name to set. |
Definition at line 508 of file class.nssm.php.
References $name.
setParams | ( | $params | ) |
Sets the parameters of the service.
string | $params | The parameters to set. |
Definition at line 568 of file class.nssm.php.
References $params.
setStart | ( | $start | ) |
setStderr | ( | $stderr | ) |
Sets the stderr path of the service.
string | $stderr | The stderr path to set. |
Definition at line 628 of file class.nssm.php.
References $stderr.
setStdout | ( | $stdout | ) |
Sets the stdout path of the service.
string | $stdout | The stdout path to set. |
Definition at line 608 of file class.nssm.php.
References $stdout.
start | ( | ) |
Starts the service.
Definition at line 288 of file class.nssm.php.
References exec(), getName(), isRunning(), and writeLog().
Referenced by restart(), and setStart().
status | ( | $timeout = true | ) |
Retrieves the status of the service.
bool | $timeout | Whether to apply a timeout for the status check. |
Definition at line 148 of file class.nssm.php.
References $latestStatus, exec(), getName(), and isPending().
Referenced by isInstalled(), isPaused(), isRunning(), and isStopped().
stop | ( | ) |
Stops the service.
Definition at line 311 of file class.nssm.php.
References exec(), getName(), isStopped(), and writeLog().
|
private |
Writes a log entry.
string | $log | The log message to write. |
Definition at line 79 of file class.nssm.php.
References $bearsamppRoot, and Util\logDebug().
Referenced by create(), delete(), isInstalled(), isPaused(), isRunning(), isStopped(), start(), and stop().
|
private |
Writes an error log entry.
string | $log | The log message to write. |
Definition at line 101 of file class.nssm.php.
References $bearsamppRoot, and Util\logError().
|
private |
Writes an informational log entry.
string | $log | The log message to write. |
Definition at line 90 of file class.nssm.php.
References $bearsamppRoot, and Util\logInfo().
Referenced by exec().
|
private |
Definition at line 53 of file class.nssm.php.
Referenced by getBinPath(), and setBinPath().
|
private |
Definition at line 52 of file class.nssm.php.
Referenced by getDisplayName(), and setDisplayName().
|
private |
Definition at line 58 of file class.nssm.php.
Referenced by getEnvironmentExtra(), and setEnvironmentExtra().
|
private |
Definition at line 59 of file class.nssm.php.
Referenced by getError(), and getLatestError().
|
private |
Definition at line 60 of file class.nssm.php.
Referenced by getLatestStatus(), and status().
|
private |
Definition at line 51 of file class.nssm.php.
Referenced by __construct(), getName(), and setName().
|
private |
Definition at line 54 of file class.nssm.php.
Referenced by getParams(), and setParams().
|
private |
Definition at line 55 of file class.nssm.php.
Referenced by getStart(), and setStart().
|
private |
Definition at line 57 of file class.nssm.php.
Referenced by getStderr(), and setStderr().
|
private |
Definition at line 56 of file class.nssm.php.
Referenced by getStdout(), and setStdout().
const INFO_APP_DIRECTORY = 'AppDirectory' |
Definition at line 41 of file class.nssm.php.
const INFO_APP_ENVIRONMENT_EXTRA = 'AppEnvironmentExtra' |
Definition at line 46 of file class.nssm.php.
const INFO_APP_PARAMETERS = 'AppParameters' |
Definition at line 43 of file class.nssm.php.
Referenced by infos(), BinMailpit\rebuildConf(), BinMemcached\rebuildConf(), and BinXlight\rebuildConf().
const INFO_APP_STDERR = 'AppStderr' |
Definition at line 44 of file class.nssm.php.
const INFO_APP_STDOUT = 'AppStdout' |
Definition at line 45 of file class.nssm.php.
const INFO_APPLICATION = 'Application' |
Definition at line 42 of file class.nssm.php.
Referenced by infos().
const PENDING_TIMEOUT = 10 |
Definition at line 48 of file class.nssm.php.
const SERVICE_AUTO_START = 'SERVICE_AUTO_START' |
Definition at line 20 of file class.nssm.php.
const SERVICE_DELAYED_START = 'SERVICE_DELAYED_START' |
Definition at line 21 of file class.nssm.php.
const SERVICE_DEMAND_START = 'SERVICE_DEMAND_START' |
Definition at line 22 of file class.nssm.php.
Referenced by BinApache\reload(), BinMailpit\reload(), BinMemcached\reload(), and BinXlight\reload().
const SERVICE_DISABLED = 'SERVICE_DISABLED' |
Definition at line 23 of file class.nssm.php.
const SERVICE_INTERACTIVE_PROCESS = 'SERVICE_INTERACTIVE_PROCESS' |
Definition at line 27 of file class.nssm.php.
const SERVICE_WIN32_OWN_PROCESS = 'SERVICE_WIN32_OWN_PROCESS' |
Definition at line 26 of file class.nssm.php.
const SLEEP_TIME = 500000 |
Definition at line 49 of file class.nssm.php.
const STATUS_CONTINUE_PENDING = 'SERVICE_CONTINUE_PENDING' |
Definition at line 30 of file class.nssm.php.
const STATUS_NA = '-1' |
Definition at line 38 of file class.nssm.php.
const STATUS_NOT_EXIST = 'SERVICE_NOT_EXIST' |
Definition at line 37 of file class.nssm.php.
const STATUS_PAUSE_PENDING = 'SERVICE_PAUSE_PENDING' |
Definition at line 31 of file class.nssm.php.
const STATUS_PAUSED = 'SERVICE_PAUSED' |
Definition at line 32 of file class.nssm.php.
const STATUS_RUNNING = 'SERVICE_RUNNING' |
Definition at line 33 of file class.nssm.php.
const STATUS_START_PENDING = 'SERVICE_START_PENDING' |
Definition at line 34 of file class.nssm.php.
const STATUS_STOP_PENDING = 'SERVICE_STOP_PENDING' |
Definition at line 35 of file class.nssm.php.
const STATUS_STOPPED = 'SERVICE_STOPPED' |
Definition at line 36 of file class.nssm.php.