YUKI Hiroshi
null+****@clear*****
Fri Sep 19 15:31:00 JST 2014
YUKI Hiroshi 2014-09-19 15:31:00 +0900 (Fri, 19 Sep 2014) New Revision: 4c227557c763c86aa25963cefc59a7cc82088501 https://github.com/droonga/droonga-http-server/commit/4c227557c763c86aa25963cefc59a7cc82088501 Message: Support the case when the service user exists but not registered as a service Modified files: bin/droonga-http-server-configure Modified: bin/droonga-http-server-configure (+21 -6) =================================================================== --- bin/droonga-http-server-configure 2014-09-18 20:25:38 +0900 (3bf8660) +++ bin/droonga-http-server-configure 2014-09-19 15:31:00 +0900 (682c737) @@ -17,10 +17,23 @@ var serviceBaseDir = '/home/' + serviceUserName + '/droonga'; var options = null; var baseDir = null; +var serviceUserExists = false; var installedAsService = false; var running = false; + +function checkServiceUserExistence(callback) { + exec('id ' + serviceUserName, function(error, stdin, stdout) { + if (!error) + serviceUserExists = true; + callback(serviceUserExists); + }); +} + function checkInstalledAsService(callback) { + if (!serviceUserName) + return callback(installedAsService); + exec('service droonga-http-server status', function(error, stdin, stdout) { if (error) { exec('SYSTEMCTL_SKIP_REDIRECT=yes service droonga-http-server status', function(error, stdin, stdout) { @@ -205,13 +218,13 @@ function tryResetStringConfigs(callback) { cacheSize: 'maximum size of the response cache', environment: 'environment' }; - if (installedAsService) { + if (serviceUserExists) { options.accessLogFile = 'droonga-http-server.access.log'; options.systemLogFile = 'droonga-http-server.system.log'; options.environment = 'production'; } - else { - if (options.quiet) + if (!installedAsService) { + if (options.quiet || serviceUserExists) configValues.pidFile = defaultConfigs.pid_file; else if (options.pidFileGiven) configValues.pidFile = options.pidFile; @@ -239,7 +252,7 @@ function tryResetBooleanConfigs(callback) { var configKeys = { enableTrustProxy: 'enable "trust proxy" configuration' }; - if (installedAsService) { + if (serviceUserExists) { configValues.daemon = true; } else if (options.daemonGiven || options.quiet) { @@ -288,7 +301,7 @@ function writeNewConfigs(callback) { var configYaml = yaml.safeDump(configs); safeWriteFileSync(configFilePath(), configYaml, { encoding: 'utf8' }); - if (installedAsService) { + if (serviceUserExists) { uid(serviceUserName, serviceGroupName, function(error, uid, gid) { fs.chownSync(configFilePath(), uid, gid); callback(); @@ -311,8 +324,9 @@ function finish() { } +checkServiceUserExistence(function() { checkInstalledAsService(function() { - if (installedAsService) + if (serviceUserExists) process.env.DROONGA_BASE_DIR = defaultConfigs.baseDir = serviceBaseDir; baseDir = defaultConfigs.baseDir; @@ -337,3 +351,4 @@ checkInstalledAsService(function() { }); }); }); +}); -------------- next part -------------- HTML����������������������������... Download