Sha256: 8b343b7099b27d7b2b2349239bc745fbe7aa8f2e52fe0fb40006ddcf909605b7
Contents?: true
Size: 1.71 KB
Versions: 3
Compression:
Stored size: 1.71 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'rubygems' PARAMS_CONFIG = {} def up require 'sinatra' require 'sinatra/base' require 'mkit' # defaults PARAMS_CONFIG[:bind] ||= 'localhost' PARAMS_CONFIG[:port] ||= 4567 MKIt.startup(options: PARAMS_CONFIG) use Rack::MethodOverride use ServicesController use MkitJobsController use MkitController # sinatra::base ignores in parameters # set it here or via configure... Sinatra::Application.run!({ port: PARAMS_CONFIG[:port], bind: PARAMS_CONFIG[:bind] }) # MKIt::Server.run end if ARGV.any? require 'optparse' parser = OptionParser.new do |op| op.on('-c config-dir', 'set the config dir (default is /etc/mkit)') { |val| PARAMS_CONFIG[:config_dir] = val } op.on('-p port', 'set the port (default is 4567)') { |val| PARAMS_CONFIG[:port] = Integer(val) } op.on('-b bind ', 'specify bind address (e.g. /tmp/app.sock)') { |val| PARAMS_CONFIG[:bind] = val } op.on('-s server', 'specify rack server/handler') { |val| PARAMS_CONFIG[:server] = val } op.on('-q', 'turn on quiet mode (default is off)') { PARAMS_CONFIG[:quiet] = true } op.on('-x', 'turn on the mutex lock (default is off)') { PARAMS_CONFIG[:lock] = true } op.on('-e env', 'set the environment (default is development)') do |val| ENV['RACK_ENV'] = val PARAMS_CONFIG[:environment] = val.to_sym end op.on('-o addr', "set the host (default is (env == 'development' ? 'localhost' : '0.0.0.0'))") do |val| PARAMS_CONFIG[:bind] = val end end begin parser.parse!(ARGV.dup) rescue StandardError => e PARAMS_CONFIG[:optparse_error] = e end end up
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mkit-0.5.0 | bin/mkitd |
mkit-0.4.3 | bin/mkitd |
mkit-0.4.2 | bin/mkitd |