Module: Kajiki
- Defined in:
- lib/kajiki.rb,
lib/kajiki/runner.rb,
lib/kajiki/handler.rb,
lib/kajiki/presets.rb
Defined Under Namespace
Modules: Handler Classes: Runner
Constant Summary collapse
- SUB_COMMANDS =
Available commands.
%w(start stop)
- OPT_DESCS =
Description strings for help display.
{ banner: "Usage: #{File.basename($0)} [options] {#{SUB_COMMANDS.join('|')}}", address: 'Bind to address', config: 'Load config from file', daemonize: 'Run in the background', error: 'Output error to file', group: 'Group to run as', log: 'Log output to file', pid: 'Store PID to file', port: 'Use port', user: 'User to run as' }
Class Method Summary collapse
-
.preset_options(preset, options = {}) ⇒ Object
Preset options for command-line parsing.
- .run(opts, &block) ⇒ Object
Class Method Details
.preset_options(preset, options = {}) ⇒ Object
Preset options for command-line parsing.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kajiki/presets.rb', line 22 def self.(preset, = {}) case preset when :minimal Optimist. do OPT_DESCS[:banner] opt :daemonize, OPT_DESCS[:daemonize] opt :pid, OPT_DESCS[:pid], type: :string end when :simple Optimist. do OPT_DESCS[:banner] opt :config, OPT_DESCS[:config], type: :string if [:config] opt :daemonize, OPT_DESCS[:daemonize] opt :error, OPT_DESCS[:error], type: :string unless [:error] == false opt :group, OPT_DESCS[:group], type: :string unless [:user] == false opt :log, OPT_DESCS[:log], type: :string opt :pid, OPT_DESCS[:pid], type: :string opt :user, OPT_DESCS[:user], type: :string unless [:user] == false depends(:user, :group) unless [:user] == false end when :server Optimist. do OPT_DESCS[:banner] opt :address, OPT_DESCS[:address], default: '0.0.0.0' opt :config, OPT_DESCS[:config], type: :string if [:config] opt :daemonize, OPT_DESCS[:daemonize] opt :error, OPT_DESCS[:error], type: :string unless [:error] == false opt :group, OPT_DESCS[:group], type: :string unless [:user] == false opt :log, OPT_DESCS[:log], type: :string opt :pid, OPT_DESCS[:pid], short: 'P', type: :string opt :port, OPT_DESCS[:port], default: 4567 opt :user, OPT_DESCS[:user], type: :string unless [:user] == false depends(:user, :group) unless [:user] == false end else fail 'Invalid preset option.' end end |
.run(opts, &block) ⇒ Object
7 8 9 |
# File 'lib/kajiki.rb', line 7 def self.run(opts, &block) Runner.run(opts, &block) end |