Class: GV::Valley::FileServer

Inherits:
Bedrock::Service
  • Object
show all
Includes:
Common::HostHelper
Defined in:
lib/gv/valley/file_server.rb

Defined Under Namespace

Classes: Api, FileSystem

Instance Method Summary collapse

Constructor Details

#initializeFileServer



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/gv/valley/file_server.rb', line 93

def initialize
  super
  ENV['GV_HOME'] ||= GV::Bedrock::Config.service.get("home")
  runner = Goliath::Runner.new(ARGV, nil)
  runner.api = Api.new
  runner.app = Goliath::Rack::Builder.build(Api, runner.api)
  runner.port = self.port
  runner.log_file = "/var/log/gv-file_server.log"
  runner.pid_file = "/var/run/gv-file_server.pid"        
  runner.daemonize = true
  runner.run
  at_exit { 
    pid = File.read("/var/run/gv-file_server.pid").chomp.to_i
    Process.kill("TERM",pid)
    File.delete("/var/run/gv-file_server.pid")          
    File.delete("/var/log/gv-file_server.log")
    File.delete("/var/log/gv-file_server.log_stdout.log")          
  }
end

Instance Method Details

#portObject



89
90
91
# File 'lib/gv/valley/file_server.rb', line 89

def port
  ENV['PORT'] ||= '9000'
end

#urlObject



85
86
87
# File 'lib/gv/valley/file_server.rb', line 85

def url
  "http://#{self.external_ip}:#{self.port}"
end