module Zashoku
Constants
- CConf
- DefConf
- EOF
- LoadPaths
- Root
- Version
Attributes
client[RW]
conf[RW]
controllers[RW]
logger[RW]
modules[RW]
server[RW]
Public Class Methods
command(message)
click to toggle source
# File lib/daemon.rb, line 21 def command(message) Zashoku.logger.debug("command got #{message}") message = message.keys.map(&:to_sym).zip(message.values).to_h obj = if controllers.key?(message[:mod]) && controllers[message[:mod]].respond_to?(message[:meth]) controllers[message[:mod]].send(message[:meth], *message[:args]) else nil end if message[:raw] Zashoku.logger.info('responding with unencoded stream') if obj.respond_to?(:gets) obj else StringIO.new(obj.to_s) end else Zashoku::Util.encode_object(obj) end end
command_server(command, host, port)
click to toggle source
# File lib/zashoku.rb, line 56 def self.command_server(command, host, port) case command when 'start' start_daemon(port) when 'restart' command_server('stop') start_daemon else require_relative 'core/net/client' Net::Client.command(host, port, command) end end
main(args)
click to toggle source
# File lib/zashoku.rb, line 22 def self.main(args) @options = Options.parse(args) host = @options[:host].key?(:host) ? @options[:host][:host] : Zashoku::CConf[:app][:net][:host] port = @options[:host].key?(:port) ? @options[:host][:port] : Zashoku::CConf[:app][:net][:port] Zashoku.modules = [] if @options[:generate] Generator.generate(@options[:template], @options[:generate_name]) elsif @options[:server_command] print command_server(@options[:server_command], host, port)[:payload] else unless command_server('up?', host, port)[:status] @options[:daemon] = true command_server('start', host, port) sleep(0.2) until command_server('up?', host, port)[:status] end Viewer.new(host: host, port: port) end end
start_daemon(port)
click to toggle source
# File lib/zashoku.rb, line 43 def self.start_daemon(port) if @options[:daemon] fork { Process.daemon() d = Daemon.new(port: port) d.listen } else d = Daemon.new(port: port) d.listen end end