Class: Fluent::Supervisor
- Inherits:
-
Object
- Object
- Fluent::Supervisor
- Defined in:
- lib/fluent/supervisor.rb
Defined Under Namespace
Classes: LoggerInitializer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opt) ⇒ Supervisor
constructor
A new instance of Supervisor.
- #options ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(opt) ⇒ Supervisor
Returns a new instance of Supervisor.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/fluent/supervisor.rb', line 114 def initialize(opt) @daemonize = opt[:daemonize] @supervise = opt[:supervise] @config_path = opt[:config_path] @inline_config = opt[:inline_config] @use_v1_config = opt[:use_v1_config] @log_path = opt[:log_path] @dry_run = opt[:dry_run] @show_plugin_config = opt[:show_plugin_config] @libs = opt[:libs] @plugin_dirs = opt[:plugin_dirs] @chgroup = opt[:chgroup] @chuser = opt[:chuser] @rpc_server = nil @process_name = nil @log_level = opt[:log_level] @suppress_interval = opt[:suppress_interval] @suppress_config_dump = opt[:suppress_config_dump] @without_source = opt[:without_source] log_opts = {suppress_repeated_stacktrace: opt[:suppress_repeated_stacktrace]} @log = LoggerInitializer.new(@log_path, @log_level, @chuser, @chgroup, log_opts) @finished = false @main_pid = nil end |
Class Method Details
.default_options ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/fluent/supervisor.rb', line 95 def self. { config_path: Fluent::DEFAULT_CONFIG_PATH, plugin_dirs: [Fluent::DEFAULT_PLUGIN_DIR], log_level: Fluent::Log::LEVEL_INFO, log_path: nil, daemonize: nil, libs: [], setup_path: nil, chuser: nil, chgroup: nil, suppress_interval: 0, suppress_repeated_stacktrace: true, without_source: false, use_v1_config: true, supervise: true, } end |
.get_etc_group(group) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/fluent/supervisor.rb', line 44 def self.get_etc_group(group) if group.to_i.to_s == group Etc.getgrgid(group.to_i) else Etc.getgrnam(group) end end |
.get_etc_passwd(user) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/fluent/supervisor.rb', line 36 def self.get_etc_passwd(user) if user.to_i.to_s == user Etc.getpwuid(user.to_i) else Etc.getpwnam(user) end end |
Instance Method Details
#options ⇒ Object
183 184 185 186 187 188 189 190 |
# File 'lib/fluent/supervisor.rb', line 183 def { 'config_path' => @config_path, 'pid_file' => @daemonize, 'plugin_dirs' => @plugin_dirs, 'log_path' => @log_path } end |
#start ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/fluent/supervisor.rb', line 141 def start @log.init show_plugin_config if @show_plugin_config read_config set_system_config dry_run if @dry_run start_daemonize if @daemonize setup_rpc_server if @rpc_endpoint setup_rpc_get_dump if @enable_get_dump if @supervise install_supervisor_signal_handlers run_rpc_server if @rpc_endpoint until @finished supervise do change_privilege init_engine install_main_process_signal_handlers run_configure finish_daemonize if @daemonize run_engine exit 0 end $log.error "fluentd main process died unexpectedly. restarting." unless @finished end else $log.info "starting fluentd-#{Fluent::VERSION} without supervision" run_rpc_server if @rpc_endpoint main_process do change_privilege init_engine install_main_process_signal_handlers run_configure finish_daemonize if @daemonize run_engine exit 0 end end stop_rpc_server if @rpc_endpoint end |