118 self::VBS_DISPLAY_NAME,
119 self::VBS_DESCRIPTION,
137 if ( function_exists( $function ) ) {
138 $result = call_user_func( $function, $param );
139 if ( $checkError && dechex(
$result ) != self::WIN32_NO_ERROR ) {
140 $this->latestError = dechex(
$result );
156 usleep( self::SLEEP_TIME );
161 while ( $this->latestStatus == self::WIN32_SERVICE_NA || $this->
isPending( $this->latestStatus ) ) {
163 if ( is_array( $this->latestStatus ) && isset( $this->latestStatus[
'CurrentState'] ) ) {
164 $this->latestStatus = dechex( $this->latestStatus[
'CurrentState'] );
166 elseif ( dechex( $this->latestStatus ) == self::WIN32_ERROR_SERVICE_DOES_NOT_EXIST ) {
167 $this->latestStatus = dechex( $this->latestStatus );
169 if ( $timeout && $maxtime < time() ) {
174 if ( $this->latestStatus == self::WIN32_ERROR_SERVICE_DOES_NOT_EXIST ) {
192 $bearsamppBins->getFilezilla()->rebuildConf();
197 $bearsamppBins->getPostgresql()->rebuildConf();
205 $nssmEnvPath .=
'%SystemRoot%/system32;';
206 $nssmEnvPath .=
'%SystemRoot%;';
207 $nssmEnvPath .=
'%SystemRoot%/system32/Wbem;';
208 $nssmEnvPath .=
'%SystemRoot%/system32/WindowsPowerShell/v1.0';
209 $this->
getNssm()->setEnvironmentExtra(
'PATH=' . $nssmEnvPath );
211 return $this->
getNssm()->create();
224 $this->
writeLog(
'Create service: ' . $create .
' (status: ' . $this->
status() .
')' );
233 if ( $create != self::WIN32_NO_ERROR ) {
250 public function delete()
266 $this->
writeLog(
'Delete service ' . $this->
getName() .
': ' . $delete .
' (status: ' . $this->
status() .
')' );
268 if ( $delete != self::WIN32_NO_ERROR && $delete != self::WIN32_ERROR_SERVICE_DOES_NOT_EXIST ) {
287 if ( $this->
delete() ) {
288 usleep( self::SLEEP_TIME );
308 $bearsamppBins->getFilezilla()->rebuildConf();
311 $bearsamppBins->getMysql()->initData();
314 $bearsamppBins->getMailhog()->rebuildConf();
317 $bearsamppBins->getMailpit()->rebuildConf();
320 $bearsamppBins->getMemcached()->rebuildConf();
323 $bearsamppBins->getPostgresql()->rebuildConf();
327 $bearsamppBins->getXlight()->rebuildConf();
334 if ( $start != self::WIN32_NO_ERROR && $start != self::WIN32_ERROR_SERVICE_ALREADY_RUNNING ) {
341 if ( !$cmdOutput[
'syntaxOk'] ) {
344 '[' . date(
'Y-m-d H:i:s', time() ) .
'] [error] ' . $cmdOutput[
'content'] . PHP_EOL,
351 if ( !$cmdOutput[
'syntaxOk'] ) {
354 '[' . date(
'Y-m-d H:i:s', time() ) .
'] [error] ' . $cmdOutput[
'content'] . PHP_EOL,
361 if ( !$cmdOutput[
'syntaxOk'] ) {
364 '[' . date(
'Y-m-d H:i:s', time() ) .
'] [error] ' . $cmdOutput[
'content'] . PHP_EOL,
375 $this->latestError =
null;
391 $this->
writeLog(
'Stop service ' . $this->
getName() .
': ' . $stop .
' (status: ' . $this->
status() .
')' );
393 if ( $stop != self::WIN32_NO_ERROR ) {
412 if ( $this->
stop() ) {
413 return $this->
start();
427 return $this->
getNssm()->infos();
440 $status = $this->
status();
441 $this->
writeLog(
'isInstalled ' . $this->
getName() .
': ' . ($status != self::WIN32_SERVICE_NA ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
453 $status = $this->
status();
454 $this->
writeLog(
'isRunning ' . $this->
getName() .
': ' . ($status == self::WIN32_SERVICE_RUNNING ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
466 $status = $this->
status();
467 $this->
writeLog(
'isStopped ' . $this->
getName() .
': ' . ($status == self::WIN32_SERVICE_STOPPED ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
479 $status = $this->
status();
480 $this->
writeLog(
'isPaused ' . $this->
getName() .
': ' . ($status == self::WIN32_SERVICE_PAUSED ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
494 return $status == self::WIN32_SERVICE_START_PENDING || $status == self::WIN32_SERVICE_STOP_PENDING
509 return 'The service continue is pending.';
513 return 'The service pause is pending.';
517 return 'The service is paused.';
521 return 'The service is running.';
525 return 'The service is starting.';
529 return 'The service is stopping.';
533 return 'The service is not running.';
537 return 'Cannot retrieve service status.';
557 return 'The handle to the SCM database does not have the appropriate access rights.';
738 if ( $this->latestError != self::WIN32_NO_ERROR ) {
740 $this->latestError .
' (' . hexdec( $this->latestError ) .
' : ' . $this->
getWin32ErrorCodeDesc( $this->latestError ) .
')';
742 elseif ( $this->latestStatus != self::WIN32_SERVICE_NA ) {
744 $this->latestStatus .
' (' . hexdec( $this->latestStatus ) .
' : ' . $this->
getWin32ServiceStatusDesc( $this->latestStatus ) .
')';
static installPostgresqlService()
static uninstallFilezillaService()
static uninstallPostgresqlService()
static installFilezillaService()
static logError($data, $file=null)
static logDebug($data, $file=null)
static logInitClass($classInstance)
static logInfo($data, $file=null)
static formatWindowsPath($path)
static getAppBinsRegKey($fromRegistry=true)
static getServiceInfos($serviceName)
const WIN32_ERROR_SERVICE_REQUEST_TIMEOUT
const WIN32_ERROR_SERVICE_EXISTS
const WIN32_ERROR_SERVICE_MARKED_FOR_DELETE
const WIN32_ERROR_SERVICE_DEPENDENCY_DELETED
const WIN32_ERROR_PATH_NOT_FOUND
const WIN32_ERROR_INVALID_NAME
const WIN32_ERROR_INVALID_HANDLE
const WIN32_ERROR_ACCESS_DENIED
const WIN32_ERROR_SHUTDOWN_IN_PROGRESS
const WIN32_ERROR_INVALID_LEVEL
const WIN32_SERVICE_STOP_PENDING
const SERVER_ERROR_IGNORE
const WIN32_ERROR_SERVICE_CANNOT_ACCEPT_CTRL
const WIN32_ERROR_SERVICE_DISABLED
const WIN32_ERROR_CIRCULAR_DEPENDENCY
getWin32ErrorCodeDesc($code)
const WIN32_SERVICE_PAUSED
const WIN32_ERROR_INVALID_SERVICE_ACCOUNT
const WIN32_ERROR_SERVICE_LOGON_FAILED
setDisplayName($displayName)
const WIN32_ERROR_FAILED_SERVICE_CONTROLLER_CONNECT
const WIN32_SERVICE_RUNNING
const WIN32_ERROR_SERVICE_DATABASE_LOCKED
const WIN32_SERVICE_START_PENDING
const WIN32_ERROR_SERVICE_ALREADY_RUNNING
const WIN32_SERVICE_CONTINUE_PENDING
callWin32Service($function, $param, $checkError=false)
const WIN32_ERROR_DATABASE_DOES_NOT_EXIST
const WIN32_ERROR_INSUFFICIENT_BUFFER
const WIN32_ERROR_DUPLICATE_SERVICE_NAME
const WIN32_ERROR_SERVICE_DOES_NOT_EXIST
const WIN32_SERVICE_PAUSE_PENDING
const WIN32_ERROR_SERVICE_DEPENDENCY_FAIL
const WIN32_SERVICE_STOPPED
setErrorControl($errorControl)
getWin32ServiceStatusDesc($status)
const WIN32_ERROR_DEPENDENT_SERVICES_RUNNING
const WIN32_ERROR_INVALID_SERVICE_CONTROL
const WIN32_ERROR_INVALID_PARAMETER
const SERVER_ERROR_NORMAL
const WIN32_ERROR_SERVICE_NOT_ACTIVE
const SERVICE_DEMAND_START
const WIN32_ERROR_SERVICE_NO_THREAD
const WIN32_ERROR_INVALID_DATA