Module: Pytty::Daemon
- Defined in:
- lib/pytty/daemon.rb,
lib/pytty/daemon/api/router.rb,
lib/pytty/daemon/api/server.rb,
lib/pytty/daemon/process_yield.rb,
lib/pytty/daemon/api/web_sockets.rb,
lib/pytty/daemon/cli/root_command.rb,
lib/pytty/daemon/cli/serve_command.rb,
lib/pytty/daemon/components/handler.rb,
lib/pytty/daemon/components/yield_handler.rb
Defined Under Namespace
Modules: Api, Cli, Components
Classes: ProcessYield
Constant Summary
collapse
- @@yields =
{}
Class Method Summary
collapse
Class Method Details
.dump ⇒ Object
11
12
13
14
|
# File 'lib/pytty/daemon.rb', line 11
def self.dump
FileUtils.mkdir_p File.dirname(yields_json)
File.write yields_json, @@yields.to_json
end
|
.load ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/pytty/daemon.rb', line 16
def self.load
return unless File.exist? yields_json
puts "restoring from #{yields_json}"
objs = JSON.parse(File.read(yields_json))
objs.each do |k,obj|
process_yield = ProcessYield.new obj["cmd"], id: obj["id"], env: obj["env"]
@@yields[obj["id"]] = process_yield
process_yield.spawn if obj["running"]
end
end
|
.pytty_path ⇒ Object
28
29
30
|
# File 'lib/pytty/daemon.rb', line 28
def self.pytty_path
File.join Dir.home, ".pytty"
end
|
.yields ⇒ Object
7
8
9
|
# File 'lib/pytty/daemon.rb', line 7
def self.yields
@@yields
end
|
.yields_json ⇒ Object
32
33
34
|
# File 'lib/pytty/daemon.rb', line 32
def self.yields_json
File.join(pytty_path,"yields.json")
end
|