Sha256: bc5b6e8c1da8d9c8e8e247c0b1bed289946f6051e6ba76ba4c8f4ade20814833

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 Bytes

Contents

require 'ptools'
require_relative 'daftos/server.rb'
require_relative 'apis/filesystem_api.rb'
require_relative 'apis/apps_api.rb'


class Daftos

  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

  def self.stop
    Dir.chdir(Dir.home)
    Process.kill 'TERM', File.read('.daftos/server.pid').to_i
  end

end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daftos-0.4.1 lib/daftos.rb
daftos-0.4.0 lib/daftos.rb