Module: Iyyov
- Includes:
- RJack
- Defined in:
- lib/iyyov/base.rb,
lib/iyyov.rb,
lib/iyyov/task.rb,
lib/iyyov/daemon.rb,
lib/iyyov/errors.rb,
lib/iyyov/context.rb,
lib/iyyov/scheduler.rb,
lib/iyyov/log_rotator.rb,
lib/iyyov/shutdown_handler.rb
Overview
– Copyright © 2010-2015 David Kellum
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ++
Defined Under Namespace
Classes: Context, Daemon, DaemonFailed, LogRotator, Scheduler, SetupError, ShutdownHandler, Task
Constant Summary collapse
- VERSION =
Iyyov version
'1.3.1'
Class Method Summary collapse
-
.context {|@context| ... } ⇒ Object
Yields current context to block.
-
.load_root_files(files) ⇒ Object
Load root configuration files.
-
.run(root_files, &block) ⇒ Object
Load configuration root_files and run the event loop, not returning.
- .set_test_context ⇒ Object
Class Method Details
.context {|@context| ... } ⇒ Object
Yields current context to block. Called from configuration scripts.
38 39 40 41 42 |
# File 'lib/iyyov.rb', line 38 def self.context raise "Iyyov.context called before run" unless @context yield @context if block_given? @context end |
.load_root_files(files) ⇒ Object
Load root configuration files.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/iyyov.rb', line 49 def self.load_root_files( files ) old_context = @context @context = Context.new @extra_config_block.call( @context ) if @extra_config_block all_success = true files.each { |cfile| all_success &&= @context.load_file( cfile, true ) } if old_context if all_success # Stop old daemons that are either: # - no longer in the newly configured context, OR: # - with exec_key changed AND a passing pre_check old_context.daemons.each do |name,odaemon| ndaemon = @context.daemons[name] if ( ndaemon.nil? || ( ndaemon.pre_check && ( ndaemon.exec_key != odaemon.exec_key ) ) ) odaemon.stop end end else @context = old_context end end all_success end |
.run(root_files, &block) ⇒ Object
Load configuration root_files and run the event loop, not returning. Yields new Context to optional block for extra configuration to be applied before any root_files are loaded.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/iyyov.rb', line 25 def self.run( root_files, &block ) @extra_config_block = block load_root_files( root_files ) continue = true while( continue && @context ) rc = @context.event_loop continue = ( rc == :shutdown ) end end |