class Daftos

Public Class Methods

start() click to toggle source
# File lib/daftos.rb, line 10
def self.start()
  fork do
    Dir.chdir(Dir.home)
    Dir.mkdir('.daftos') unless Dir.exist?('.daftos')
    File.open('.daftos/server.pid', 'w') {|f| f.write Process.pid }
    
    builder = Rack::Builder.new do
      map('/api/file_system'){ run FileSystemAPI }
      map('/api/apps'){ run AppsAPI }
      map('/'){ run Server }
    end
    Rack::Handler::Thin.run builder, :Port => 9999, :Host => "0.0.0.0"

  end
end
stop() click to toggle source
# File lib/daftos.rb, line 26
def self.stop
  Dir.chdir(Dir.home)
  Process.kill 'TERM', File.read('.daftos/server.pid').to_i
end