Module: Houston
- Extended by:
- Extensions
- Defined in:
- lib/houston/cli.rb,
lib/houston/try.rb,
lib/houston/version.rb,
lib/houston/adapters.rb,
lib/houston/boot/timer.rb,
lib/houston/boot/actions.rb,
lib/houston/test_helpers.rb,
lib/houston/boot/observer.rb,
lib/houston/boot/provider.rb,
lib/houston/boot/triggers.rb,
app/concerns/houston/props.rb,
lib/houston/boot/daemonize.rb,
lib/houston/boot/extensions.rb,
lib/houston/boot/running_as.rb,
lib/houston/boot/serializer.rb,
lib/houston/params_serializer.rb,
lib/houston/boot/configuration.rb,
lib/houston/boot/extensions/dsl.rb,
lib/houston/boot/extensions/view.rb,
lib/houston/boot/extensions/oauth.rb,
lib/houston/boot/extensions/events.rb,
lib/houston/boot/extensions/layout.rb,
lib/houston/boot/extensions/features.rb,
lib/houston/boot/extensions/deprecated.rb,
lib/houston/boot/extensions/navigation.rb,
lib/houston/boot/extensions/serializers.rb,
lib/houston/boot/serializers/active_record_serializer.rb,
lib/houston/boot/serializers/readonly_hash_serializer.rb
Defined Under Namespace
Modules: Adapters, Extensions, Props, TestHelpers
Classes: Actions, ActiveRecordSerializer, CLI, ColorValue, Configuration, DuplicateTriggerError, MissingConfiguration, Module, NotConfigured, Observer, ParamsSerializer, Provider, ReadonlyHash, ReadonlyHashSerializer, Serializer, Timer, Trigger, Triggers
Constant Summary
collapse
- VERSION =
"0.9.2"
Class Method Summary
collapse
Methods included from Extensions
add_serializer, events, layout, navigation, oauth, project_features, register_events, serializers, view
#add_navigation_renderer, #add_project_column, #add_project_feature, #add_project_header_command, #add_project_option, #add_user_option, #project_header_commands
Class Method Details
.actions ⇒ Object
474
475
476
|
# File 'lib/houston/boot/configuration.rb', line 474
def actions
config.actions
end
|
.config(&block) ⇒ Object
457
458
459
460
461
462
463
464
|
# File 'lib/houston/boot/configuration.rb', line 457
def config(&block)
@configuration ||= Configuration.new
if block_given?
@configuration.instance_eval(&block)
@configuration.validate!
end
@configuration
end
|
.daemonize(name) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/houston/boot/daemonize.rb', line 3
def self.daemonize(name)
unless Houston.running_as_web_server? or ENV["HOUSTON_DAEMONS"].to_s.split(",").member?(name)
puts "\e[94m[daemon:#{name}] Skipping daemon since we're not running as a server\e[0m" if Rails.env.development?
Rails.logger.info "\e[94m[daemon:#{name}] Skipping daemon since we're not running as a server\e[0m"
return
end
puts "\e[94m[daemon:#{name}] Connecting\e[0m" if Rails.env.development?
Rails.logger.info "\e[94m[daemon:#{name}] Connecting\e[0m"
Thread.new do
begin
connected_at = Time.now
Houston.observer.fire "daemon:#{name}:start"
yield
rescue Exception
puts "\e[91m#{$!.class}: #{$!.message}\e[0m" if Rails.env.development?
Houston.report_exception $!
unless (Time.now - connected_at) < 60
Houston.observer.fire "daemon:#{name}:restart"
retry
end
end
puts "\e[31m[daemon:#{name}] Disconnected\e[0m" if Rails.env.development?
Rails.logger.error "\e[31m[daemon:#{name}] Disconnected\e[0m"
Rails.logger.flush
Houston.observer.fire "daemon:#{name}:stop"
end
end
|
.deprecation_notice(message, stack_offset = 1) ⇒ Object
15
16
17
18
|
# File 'lib/houston/boot/configuration.rb', line 15
def deprecation_notice(message, stack_offset=1)
message = message.gsub /<b>(.*)<\/b>/, "\e[1m\\1\e[0;34m"
puts "\e[34mDEPRECATION: #{message}\e[0;90m\n#{caller[stack_offset]}\e[0m\n\n"
end
|
.observer ⇒ Object
470
471
472
|
# File 'lib/houston/boot/configuration.rb', line 470
def observer
config.observer
end
|
.reconnect(options = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/houston/try.rb', line 26
def self.reconnect(options={})
max_tries = options.fetch(:max_tries, 2)
tries = 1
begin
yield
rescue exceptions_wrapping(PG::ConnectionBad)
ActiveRecord::Base.connection.reconnect!
retry unless (tries += 1) > 2
raise
end
end
|
.root ⇒ Object
482
483
484
|
# File 'lib/houston/boot/configuration.rb', line 482
def root
config.root
end
|
.running_as ⇒ Object
11
12
13
|
# File 'lib/houston/boot/running_as.rb', line 11
def self.running_as
@__process_type ||= discover_process_type
end
|
.timer ⇒ Object
478
479
480
|
# File 'lib/houston/boot/configuration.rb', line 478
def timer
config.timer
end
|
.triggers ⇒ Object
466
467
468
|
# File 'lib/houston/boot/configuration.rb', line 466
def triggers
config.triggers
end
|
.try(options, *rescue_from) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/houston/try.rb', line 3
def self.try(options, *rescue_from)
options = { max_tries: options } if options.is_a?(Fixnum)
options = {} unless options.is_a?(Hash)
max_tries = options.fetch :max_tries, 3
base = options.fetch :base, 2
ignore = options.fetch :ignore, false
rescue_from = [StandardError] if rescue_from.empty?
tries = 1
begin
yield tries
rescue *rescue_from
if tries > max_tries
return if ignore
raise
end
Rails.logger.warn "\e[31m[try] \e[1m#{$!.class}\e[0;31m: #{$!.message}\e[0m"
sleep base ** tries
tries += 1
retry
end
end
|