Module: Nodectl
- Defined in:
- lib/nodectl.rb,
lib/nodectl/version.rb
Defined Under Namespace
Modules: Generators, Stream, Webapp Classes: Action, Binding, CLI, Context, Database, Instance, Log, Manager, MultiIO, Options, Process, PromisedFile, Recipe, Repository, Server, Service, Watchdog
Constant Summary collapse
- NotFound =
Class.new(Sinatra::NotFound)
- VERSION =
"0.2.4"
Class Attribute Summary collapse
-
.options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.assets_path ⇒ String
Base path of assets folder.
-
.boot(options = {}) ⇒ Object
Node initialization: here default global options could be overriden.
-
.database ⇒ Nodectl::Database
Key-value store for node.
-
.logger ⇒ Logger
Get logger instance.
-
.manifest ⇒ Array
Get node manifest: list of hashes with service definitions.
- .server ⇒ Object
-
.shut_up! ⇒ Object
Redirect all standard streams to null device.
Class Attribute Details
.options ⇒ Object (readonly)
Returns the value of attribute options.
61 62 63 |
# File 'lib/nodectl.rb', line 61 def @options end |
Class Method Details
.assets_path ⇒ String
Base path of assets folder
131 132 133 |
# File 'lib/nodectl.rb', line 131 def assets_path File.absolute_path(File.join(__FILE__, "../../assets")) end |
.boot(options = {}) ⇒ Object
Node initialization: here default global options could be overriden
66 67 68 69 70 71 72 73 |
# File 'lib/nodectl.rb', line 66 def boot( = {}) @options = Options.new() # Routing targets Dir["#{@options[:recipe_dir]}/**/*.rb"].each do |path| require path end end |
.database ⇒ Nodectl::Database
Key-value store for node
78 79 80 |
# File 'lib/nodectl.rb', line 78 def database @database ||= Nodectl::Database.new([:database]) end |
.logger ⇒ Logger
Get logger instance
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/nodectl.rb', line 108 def logger unless defined? @logger file = File.open([:logger_dir].join("nodectl.log"), "a") file.sync = true io = MultiIO.new(STDOUT, file) @logger ||= Logger.new(io) @logger.level = Logger.const_get([:log_level]) end @logger end |
.manifest ⇒ Array
Get node manifest: list of hashes with service definitions. It looks like:
[
{
"name" => "hub",
"repo" => "git://example.com:service.git",
"path" => "hub"
},
...
]
98 99 100 101 102 103 |
# File 'lib/nodectl.rb', line 98 def manifest @manifest ||= YAML.load_file(@options[:manifest]) || [] rescue SystemCallError => e $stderr.puts "Manifest loading error: #{e.}" abort end |
.server ⇒ Object
82 83 84 |
# File 'lib/nodectl.rb', line 82 def server @server ||= Nodectl::Server.new() end |
.shut_up! ⇒ Object
Redirect all standard streams to null device
122 123 124 125 126 |
# File 'lib/nodectl.rb', line 122 def shut_up! $stdout.reopen(File.open(File::NULL, "w")) $stderr.reopen(File.open(File::NULL, "w")) $stdin.reopen(File.open(File::NULL, "r")) end |