2024.8.23
|
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.
Nssm::__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().
Nssm::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(), SERVICE_DEMAND_START, and writeLog().
Nssm::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().
Nssm::getBinPath | ( | ) |
Gets the binary path of the service.
Definition at line 538 of file class.nssm.php.
References $binPath.
Referenced by create().
Nssm::getDisplayName | ( | ) |
Gets the display name of the service.
Definition at line 518 of file class.nssm.php.
References $displayName.
Referenced by create().
Nssm::getEnvironmentExtra | ( | ) |
Gets the additional environment variables for the service.
Definition at line 638 of file class.nssm.php.
References $environmentExtra.
Referenced by create().
Nssm::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.
Nssm::getLatestError | ( | ) |
Gets the latest error message related to the service.
Definition at line 668 of file class.nssm.php.
References $latestError.
Nssm::getLatestStatus | ( | ) |
Gets the latest status of the service.
Definition at line 658 of file class.nssm.php.
References $latestStatus.
Nssm::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().
Nssm::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.
References STATUS_CONTINUE_PENDING, STATUS_NA, STATUS_PAUSE_PENDING, STATUS_PAUSED, STATUS_RUNNING, STATUS_START_PENDING, STATUS_STOP_PENDING, and STATUS_STOPPED.
Nssm::getStart | ( | ) |
Gets the start type of the service.
Definition at line 578 of file class.nssm.php.
References $start.
Referenced by create().
Nssm::getStderr | ( | ) |
Gets the stderr path of the service.
Definition at line 618 of file class.nssm.php.
References $stderr.
Referenced by create().
Nssm::getStdout | ( | ) |
Gets the stdout path of the service.
Definition at line 598 of file class.nssm.php.
References $stdout.
Referenced by create().
Nssm::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.
Nssm::isInstalled | ( | ) |
Checks if the service is installed.
Definition at line 394 of file class.nssm.php.
References getName(), status(), STATUS_NA, and writeLog().
Referenced by create(), and delete().
Nssm::isPaused | ( | ) |
Checks if the service is paused.
Definition at line 433 of file class.nssm.php.
References getName(), status(), STATUS_PAUSED, and writeLog().
Nssm::isPending | ( | $status | ) |
Checks if the service status is pending.
string | $status | The status to check. |
Definition at line 448 of file class.nssm.php.
References STATUS_PAUSE_PENDING.
Referenced by status().
Nssm::isRunning | ( | ) |
Checks if the service is running.
Definition at line 407 of file class.nssm.php.
References getName(), status(), STATUS_RUNNING, and writeLog().
Referenced by start().
Nssm::isStopped | ( | ) |
Checks if the service is stopped.
Definition at line 420 of file class.nssm.php.
References getName(), status(), STATUS_STOPPED, and writeLog().
Referenced by stop().
Nssm::restart | ( | ) |
Restarts the service.
Definition at line 334 of file class.nssm.php.
Nssm::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().
Nssm::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.
Nssm::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().
Nssm::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.
Nssm::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.
Nssm::setStart | ( | $start | ) |
Nssm::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.
Nssm::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.
Nssm::start | ( | ) |
Starts the service.
Definition at line 288 of file class.nssm.php.
References exec(), getName(), isRunning(), and writeLog().
Referenced by restart(), and setStart().
Nssm::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(), isPending(), PENDING_TIMEOUT, STATUS_NA, and STATUS_NOT_EXIST.
Referenced by isInstalled(), isPaused(), isRunning(), and isStopped().
Nssm::stop | ( | ) |
Stops the service.
Definition at line 311 of file class.nssm.php.
References exec(), getName(), isStopped(), and writeLog().
Referenced by delete(), and restart().
|
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 Nssm::INFO_APP_DIRECTORY = 'AppDirectory' |
Definition at line 41 of file class.nssm.php.
const Nssm::INFO_APP_ENVIRONMENT_EXTRA = 'AppEnvironmentExtra' |
Definition at line 46 of file class.nssm.php.
const Nssm::INFO_APP_PARAMETERS = 'AppParameters' |
Definition at line 43 of file class.nssm.php.
Referenced by infos(), BinMailhog\rebuildConf(), BinMailpit\rebuildConf(), BinMemcached\rebuildConf(), and BinXlight\rebuildConf().
const Nssm::INFO_APP_STDERR = 'AppStderr' |
Definition at line 44 of file class.nssm.php.
const Nssm::INFO_APP_STDOUT = 'AppStdout' |
Definition at line 45 of file class.nssm.php.
const Nssm::INFO_APPLICATION = 'Application' |
Definition at line 42 of file class.nssm.php.
Referenced by infos().
const Nssm::PENDING_TIMEOUT = 10 |
Definition at line 48 of file class.nssm.php.
Referenced by status().
const Nssm::SERVICE_AUTO_START = 'SERVICE_AUTO_START' |
Definition at line 20 of file class.nssm.php.
const Nssm::SERVICE_DELAYED_START = 'SERVICE_DELAYED_START' |
Definition at line 21 of file class.nssm.php.
const Nssm::SERVICE_DEMAND_START = 'SERVICE_DEMAND_START' |
Definition at line 22 of file class.nssm.php.
Referenced by create(), BinApache\reload(), BinMailhog\reload(), BinMailpit\reload(), BinMemcached\reload(), and BinXlight\reload().
const Nssm::SERVICE_DISABLED = 'SERVICE_DISABLED' |
Definition at line 23 of file class.nssm.php.
const Nssm::SERVICE_INTERACTIVE_PROCESS = 'SERVICE_INTERACTIVE_PROCESS' |
Definition at line 27 of file class.nssm.php.
const Nssm::SERVICE_WIN32_OWN_PROCESS = 'SERVICE_WIN32_OWN_PROCESS' |
Definition at line 26 of file class.nssm.php.
const Nssm::SLEEP_TIME = 500000 |
Definition at line 49 of file class.nssm.php.
const Nssm::STATUS_CONTINUE_PENDING = 'SERVICE_CONTINUE_PENDING' |
Definition at line 30 of file class.nssm.php.
Referenced by getServiceStatusDesc().
const Nssm::STATUS_NA = '-1' |
Definition at line 38 of file class.nssm.php.
Referenced by getServiceStatusDesc(), isInstalled(), and status().
const Nssm::STATUS_NOT_EXIST = 'SERVICE_NOT_EXIST' |
Definition at line 37 of file class.nssm.php.
Referenced by status().
const Nssm::STATUS_PAUSE_PENDING = 'SERVICE_PAUSE_PENDING' |
Definition at line 31 of file class.nssm.php.
Referenced by getServiceStatusDesc(), and isPending().
const Nssm::STATUS_PAUSED = 'SERVICE_PAUSED' |
Definition at line 32 of file class.nssm.php.
Referenced by getServiceStatusDesc(), and isPaused().
const Nssm::STATUS_RUNNING = 'SERVICE_RUNNING' |
Definition at line 33 of file class.nssm.php.
Referenced by getServiceStatusDesc(), and isRunning().
const Nssm::STATUS_START_PENDING = 'SERVICE_START_PENDING' |
Definition at line 34 of file class.nssm.php.
Referenced by getServiceStatusDesc().
const Nssm::STATUS_STOP_PENDING = 'SERVICE_STOP_PENDING' |
Definition at line 35 of file class.nssm.php.
Referenced by getServiceStatusDesc().
const Nssm::STATUS_STOPPED = 'SERVICE_STOPPED' |
Definition at line 36 of file class.nssm.php.
Referenced by getServiceStatusDesc(), and isStopped().