Sha256: 3d71b269ef550935e8301c45b41eb4151e9b396a5db608546a6bf82ef99ed616

Contents?: true

Size: 1.12 KB

Versions: 18

Compression:

Stored size: 1.12 KB

Contents

require 'thor'
require 'grape'
require 'grape-route-helpers'
require 'site_hook/webhook'
require 'thin'
require 'site_hook/config'
require 'super_callbacks'
module SiteHook
  module Commands
    class ServerClass < Thor


      # def __version
      # puts SiteHook::VERSION
      # end
      # map ['-v', '--version'] => __version
      method_option(:host, banner: 'HOST', aliases: ['-h'], type: :string, default: SiteHook::Config.webhook.host)
      method_option(:port, banner: 'PORT', aliases: ['-p'], type: :numeric, default: SiteHook::Config.webhook.port)
      desc 'listen [options]', ''
      def listen
        $threads << Thread.new do
          ::Thin::Server.start(options[:host], options[:port], SiteHook::Server, debug: true)
        end
        $threads << Thread.new do
          loop do
            case $stdin.gets
            when "reload\n"
              ::SiteHook::Config.reload!
            when "quit\n"
              $threads.each do |thr|
                thr == Thread.current ? exit(0) : thr.exit
              end
            end
          end
        end
        $threads.each(&:join)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
site_hook-1.0.21 lib/site_hook/commands/server_class.rb
site_hook-1.0.20 lib/site_hook/commands/server_class.rb
site_hook-1.0.19 lib/site_hook/commands/server_class.rb
site_hook-1.0.18 lib/site_hook/commands/server_class.rb
site_hook-1.0.17 lib/site_hook/commands/server_class.rb
site_hook-1.0.16 lib/site_hook/commands/server_class.rb
site_hook-1.0.15 lib/site_hook/commands/server_class.rb
site_hook-1.0.14 lib/site_hook/commands/server_class.rb
site_hook-1.0.13 lib/site_hook/commands/server_class.rb
site_hook-1.0.12 lib/site_hook/commands/server_class.rb
site_hook-1.0.11 lib/site_hook/commands/server_class.rb
site_hook-1.0.10 lib/site_hook/commands/server_class.rb
site_hook-1.0.9 lib/site_hook/commands/server_class.rb
site_hook-1.0.8 lib/site_hook/commands/server_class.rb
site_hook-1.0.4 lib/site_hook/commands/server_class.rb
site_hook-1.0.3 lib/site_hook/commands/server_class.rb
site_hook-1.0.2 lib/site_hook/commands/server_class.rb
site_hook-1.0.1 lib/site_hook/commands/server_class.rb