Class: Trema::App
- Inherits:
-
NetworkComponent
- Object
- NetworkComponent
- Trema::App
- Includes:
- Daemon
- Defined in:
- ruby/trema/app.rb
Overview
Trema applications
Instance Attribute Summary (collapse)
-
- (Trema::DSL::Stanza) stanza
readonly
A map of key-value pair settings for trema's dsl run{} syntax.
Instance Method Summary (collapse)
-
- (String) command
private
Returns application's command to execute.
-
- (App) daemonize!
Runs as a daemon.
-
- (App) initialize(stanza)
constructor
Creates a new Trema application from DSL::Run.
-
- (String) name
Returns the name of application.
Methods included from Daemon
#pid_file, #restart!, #run, #run!, #running?, #shutdown, #shutdown!
Methods inherited from NetworkComponent
[], add, clear, each, inherited, size
Constructor Details
- (App) initialize(stanza)
Creates a new Trema application from DSL::Run
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'ruby/trema/app.rb', line 51 def initialize stanza @stanza = stanza if /\.rb\Z/=~ @stanza.fetch( :name ) # ruby? require "trema" path = @stanza.fetch( :path ) ARGV.replace [ path ] $LOAD_PATH << File.dirname( path ) Trema.module_eval IO.read( path ) else App.add self end end |
Instance Attribute Details
- (Trema::DSL::Stanza) stanza (readonly)
A map of key-value pair settings for trema's dsl run{} syntax.
35 36 37 |
# File 'ruby/trema/app.rb', line 35 def stanza @stanza end |
Instance Method Details
- (String) command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns application's command to execute
103 104 105 |
# File 'ruby/trema/app.rb', line 103 def command "#{ @stanza[ :path ] } --name #{ name }" end |
- (App) daemonize!
Runs as a daemon
90 91 92 93 |
# File 'ruby/trema/app.rb', line 90 def daemonize! sh [ command, "-d", @stanza[ :options ] ].compact.join( " " ) self end |
- (String) name
Returns the name of application
75 76 77 |
# File 'ruby/trema/app.rb', line 75 def name @stanza[ :name ] end |