Sha256: 806e78047d98baeadff71471195cb4b808d8a7e088a52c970391c1f1e3064bd1

Contents?: true

Size: 1.74 KB

Versions: 11

Compression:

Stored size: 1.74 KB

Contents

Capricorn.runtime_gem('thor', Capricorn::THOR_VERSION)

module Capricorn
  module Apps
    
    class Server < Thor
      
      desc "start", 'start the server'
      method_options :foreground => :boolean,  :config => :optional
      def start
        Capricorn.server? true
        Capricorn::System.load!(options[:root_path])
        
        begin
          FileUtils.mkdir_p(Capricorn.system.root)
        rescue Errno::EACCES
          Capricorn.logger.out.fatal "must be executed as root"
          exit(1)
        end
        
        unless Capricorn.system.is_user('root')
          Capricorn.logger.out.fatal "must be executed as root"
          exit(1)
        end
        
        if options[:foreground]
          Capricorn::Server.start
        else
          Capricorn::Server.daemonize
        end
      end
      
      desc "stop", 'stop the server'
      method_options :token => :optional
      def stop
        Capricorn.client(options[:token]).stop_server
      end
      
      desc "restart", 'restart the server'
      method_options :token => :optional
      def restart
        Capricorn.client(options[:token]).restart_server
      end
      
      desc "reload", 'reload the server'
      method_options :token => :optional
      def reload
        Capricorn.client(options[:token]).reload_server
      end
      
      desc "update", 'update the capricorn'
      method_options :token => :optional
      def update
        Capricorn.client(options[:token]).update_server
      end
      
      desc "version", 'version of the server'
      method_options :token => :optional
      def version
        puts "Client: #{Capricorn.version}"
        puts "Server: #{Capricorn.client(options[:token]).server_version}"
      end
      
    end
    
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
simonmenke-capricorn-0.2.00 lib/capricorn/apps/server.rb
simonmenke-capricorn-0.2.03 lib/capricorn/apps/server.rb
simonmenke-capricorn-0.2.07 lib/capricorn/apps/server.rb
capricorn-0.2.07 lib/capricorn/apps/server.rb
capricorn-0.2.06 lib/capricorn/apps/server.rb
capricorn-0.2.05 lib/capricorn/apps/server.rb
capricorn-0.2.04 lib/capricorn/apps/server.rb
capricorn-0.2.03 lib/capricorn/apps/server.rb
capricorn-0.2.02 lib/capricorn/apps/server.rb
capricorn-0.2.01 lib/capricorn/apps/server.rb
capricorn-0.2.00 lib/capricorn/apps/server.rb