YUKI Hiroshi
null+****@clear*****
Wed Sep 24 18:59:55 JST 2014
YUKI Hiroshi 2014-09-24 18:59:55 +0900 (Wed, 24 Sep 2014) New Revision: eee2baeeaf14d8e538cecf41c5ef949a4dc8bb54 https://github.com/droonga/droonga-engine/commit/eee2baeeaf14d8e538cecf41c5ef949a4dc8bb54 Message: Make droonga-engine-configure available only for service installation Modified files: bin/droonga-engine-configure lib/droonga/service_installation.rb Modified: bin/droonga-engine-configure (+6 -38) =================================================================== --- bin/droonga-engine-configure 2014-09-24 18:51:07 +0900 (da6da06) +++ bin/droonga-engine-configure 2014-09-24 18:59:55 +0900 (575673b) @@ -95,7 +95,7 @@ service_installation.ensure_using_service_base_directory running = false begin - if service_installation.running?(configuration.pid_file_path) + if service_installation.running? if !options[:quiet] puts("The droonga-engine service is now running.") puts("Before reconfiguration, the service is going to be stopped " + @@ -106,8 +106,8 @@ begin end running = true end -rescue Droonga::ServiceInstallation::MissingPidFilePath - puts("Couldn't detect running status of the service.") +rescue Droonga::NotInstalledAsService::MissingPidFilePath + puts("Not installed as a service yet.") end unless service_installation.have_write_permission? @@ -145,7 +145,7 @@ end if running unjoin(configuration) - service_installation.stop_service(configuration.pid_file_path) + service_installation.stop end if options[:clear] @@ -175,52 +175,20 @@ if options[:reset_config] or options[:reset_catalog] end if options[:reset_config] - if service_installation.user_exist? - daemon = true - elsif configuration.have_given_daemon? or options[:quiet] - daemon = configuration.daemon? - else - daemon = confirmed?("run as a daemon?") - end - - if service_installation.user_exist? - log_file = Droonga::Path.default_log_file - elsif configuration.have_given_log_file? - log_file = configuration.log_file - elsif options[:quiet] - log_file = Droonga::Path.default_log_file - else - log_file = input("path to the log file", Droonga::Path.default_log_file) - end - if configuration.have_given_log_level? or options[:quiet] log_level = configuration.log_level else log_level = input("log level", configuration.log_level) end - pid_file_path = nil - unless service_installation.installed_as_service? - if options[:quiet] or service_installation.user_exist? - pid_file_path = Droonga::Path.default_pid_file - elsif configuration.have_given_pid_file? - pid_file_path = configuration.pid_file_path - else - pid_file_path = input("path to the PID file", Droonga::Path.default_pid_file) - end - end - new_configuration = { "host" => host, "port" => port, "tag" => tag, - "daemon" => daemon, - "log_file" => path_from_base_dir(log_file), + "daemon" => true, + "log_file" => path_from_base_dir(Droonga::Path.default_log_file), "log_level" => log_level, } - unless pid_file_path.nil? - new_configuration["pid_file"] = path_from_base_dir(pid_file_path) - end Droonga::SafeFileWriter.write(Droonga::Path.config, YAML.dump(new_configuration)) end Modified: lib/droonga/service_installation.rb (+13 -36) =================================================================== --- lib/droonga/service_installation.rb 2014-09-24 18:51:07 +0900 (eaa47b9) +++ lib/droonga/service_installation.rb 2014-09-24 18:59:55 +0900 (8fbb5ae) @@ -22,7 +22,7 @@ module Droonga class << self end - class MissingPidFilePath < ArgumentError + class NotInstalledAsService < StandardError end def user_name @@ -93,46 +93,23 @@ module Droonga end def running?(pid_file_path=nil) - if installed_as_service? - result = `env SYSTEMCTL_SKIP_REDIRECT=yes service droonga-engine status` - result.include?("running") - else - if pid_file_path.nil? - raise MissingPidFilePath.new - end - system("droonga-engine-status", - "--base-dir", Path.base.to_s, - "--pid-file", pid_file_path.to_s, - :out => "/dev/null", - :err => "/dev/null") - end + raise NotInstalledAsService.new unless installed_as_service? + result = `env SYSTEMCTL_SKIP_REDIRECT=yes service droonga-engine status` + result.include?("running") end def start - if installed_as_service? - system("service", "droonga-engine", "start", - :out => "/dev/null", - :err => "/dev/null") - else - false - end + raise NotInstalledAsService.new unless installed_as_service? + system("service", "droonga-engine", "start", + :out => "/dev/null", + :err => "/dev/null") end - def stop(pid_file_path=nil) - if installed_as_service? - system("service", "droonga-engine", "stop", - :out => "/dev/null", - :err => "/dev/null") - else - if pid_file_path.nil? - raise MissingPidFilePath.new - end - system("droonga-engine-stop", - "--base-dir", Path.base.to_s, - "--pid-file", pid_file_path.to_s, - :out => "/dev/null", - :err => "/dev/null") - end + def stop + raise NotInstalledAsService.new unless installed_as_service? + system("service", "droonga-engine", "stop", + :out => "/dev/null", + :err => "/dev/null") end end end -------------- next part -------------- HTML����������������������������... Download