Sha256: 20abb0a8e9f1de52bc8f6bdfe018e8b3f637f69ec7048c1fe8dd93c8b3c0af22

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'thor/group'

# NOTE: On Windows Process.fork is implemented in a way
# that it re-starts the parent command with an additional "child#0"
# argument. Naturally, this leads to Thor rejecting that 2nd invocation
# since the original command is not supposed to have arguments.
# To overcome this issue all Background commands
# should be inside their own Thor::Group-derived class 
# which declares an additional optional argument (which is not used)
# but exists merely to support Windows Process.fork artificial implementation
class StartBg < Thor::Group
  argument :childname, :optional => true
  #desc "startbg", "Start rhoconnect server in bg mode (Rhostudio) - this is an internal command"
  def startbg
    cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
    require 'win32/process' if windows?
    
    p1 = Process.fork {  
      if windows?
        puts 'Starting rhoconnect ...'
        system("#{cmd} config.ru -P #{rhoconnect_pid}")
      elsif jruby?
        puts 'Starting rhoconnect in jruby environment...'
        system("#{cmd}")
      else
        system("bundle exec #{cmd} config.ru -P #{rhoconnect_pid}")
      end
    }
    Process.detach(p1)
    
    exit
  end #startbg
end
Execute.register StartBg, "startbg", "startbg", "Start rhoconnect server in bg mode (Rhostudio) - this is an internal command", :hide => true

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rhoconnect-3.2.0.beta2 commands/commands/rhoconnect/startbg.rb
rhoconnect-3.2.0.beta1 commands/commands/rhoconnect/startbg.rb