60 $this->enable = $this->enable &&
$bearsamppConfig->getRaw(self::ROOT_CFG_ENABLE);
64 if ($this->bearsamppConfRaw !==
false) {
66 $this->memory = intval($this->bearsamppConfRaw[self::LOCAL_CFG_MEMORY]);
67 $this->port = intval($this->bearsamppConfRaw[self::LOCAL_CFG_PORT]);
74 if (!is_dir($this->currentPath)) {
78 if (!is_dir($this->symlinkPath)) {
82 if (!is_file($this->bearsamppConf)) {
86 if (!is_file($this->exe)) {
90 if (empty($this->memory)) {
94 if (empty($this->port)) {
99 $nssm =
new Nssm(self::SERVICE_NAME);
101 $nssm->setBinPath($this->exe);
102 $nssm->setParams(sprintf(self::SERVICE_PARAMS, $this->memory, $this->port));
104 $nssm->setStdout(
$bearsamppRoot->getLogsPath() .
'/memcached.out.log');
105 $nssm->setStderr(
$bearsamppRoot->getLogsPath() .
'/memcached.err.log');
107 $this->service->setNssm($nssm);
116 $content = file_get_contents($this->bearsamppConf);
118 foreach ($params as $key => $value) {
119 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value.
'"', $content);
120 $this->bearsamppConfRaw[$key] = $value;
123 $this->memory = intval($value);
126 $this->port = intval($value);
131 file_put_contents($this->bearsamppConf, $content);
140 global $bearsamppRegistry;
142 $exists = $bearsamppRegistry->exists(
144 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
148 return $bearsamppRegistry->setExpandStringValue(
150 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
152 sprintf(self::SERVICE_PARAMS, $this->memory, $this->port)
168 global $bearsamppWinbinder;
176 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
179 if (!$checkUsed || $isPortInUse ===
false) {
182 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
186 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
211 if (function_exists(
'memcache_connect')) {
212 $memcache = @memcache_connect(
'127.0.0.1',
$port);
214 $memcacheVersion = memcache_get_version($memcache);
216 memcache_close($memcache);
218 $bearsamppWinbinder->messageBoxInfo(
226 $fp = @fsockopen(
'127.0.0.1',
$port, $errno, $errstr, 3);
230 $bearsamppWinbinder->messageBoxWarning(
238 $bearsamppWinbinder->messageBoxError(
273 if (!$this->enable) {
278 Util::logDebug(($sub > 0 ? str_repeat(
' ', 2 * $sub) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config');
286 $bearsamppWinbinder->messageBoxError(
298 $bearsamppWinbinder->messageBoxError(
339 public function setEnable($enabled, $showWindow =
false) {
345 $bearsamppWinbinder->messageBoxError(
switchVersion($version, $showWindow=false)
setEnable($enabled, $showWindow=false)
changePort($port, $checkUsed=false, $wbProgressBar=null)
updateConfig($version=null, $sub=0, $showWindow=false)
reload($id=null, $type=null)
checkPort($port, $showWindow=false)
const ERROR_FILE_NOT_FOUND
const ERROR_INVALID_PARAMETER
const BEARSAMPP_CONF_NOT_FOUND_ERROR
const ENABLE_BUNDLE_NOT_EXIST
const ERROR_CONF_NOT_FOUND
const SWITCH_VERSION_TITLE
const ERROR_EXE_NOT_FOUND
const BEARSAMPP_CONF_MALFORMED_ERROR
update($sub=0, $showWindow=false)
const SERVICE_DEMAND_START
const INFO_APP_PARAMETERS
static logReloadClass($classInstance)
static logError($data, $file=null)
static isValidPort($port)
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)
static removeService($service, $name)
static logDebug($data, $file=null)
static logInitClass($classInstance)
static isPortInUse($port)
static logInfo($data, $file=null)