Module: Eye::Process::Data
- Included in:
- ChildProcess, Eye::Process
- Defined in:
- lib/eye/process/data.rb
Instance Method Summary collapse
- #app_name ⇒ Object
- #debug_data ⇒ Object
- #environment_string ⇒ Object
- #full_name ⇒ Object
- #group_name ⇒ Object
- #group_name_pure ⇒ Object
- #logger_tag ⇒ Object
- #self_status_data(opts) ⇒ Object
- #shell_string(dir = true) ⇒ Object
- #status_data(opts = {}) ⇒ Object
- #sub_object?(obj) ⇒ Boolean
- #timers_data ⇒ Object
Instance Method Details
#app_name ⇒ Object
7 8 9 |
# File 'lib/eye/process/data.rb', line 7 def app_name self[:application] end |
#debug_data ⇒ Object
54 55 56 |
# File 'lib/eye/process/data.rb', line 54 def debug_data { queue: scheduler_actions_list, watchers: @watchers.keys, timers: timers_data } end |
#environment_string ⇒ Object
72 73 74 75 76 |
# File 'lib/eye/process/data.rb', line 72 def environment_string s = [] @config[:environment].each { |k, v| s << "#{k}=#{v}" } s * ' ' end |
#full_name ⇒ Object
19 20 21 |
# File 'lib/eye/process/data.rb', line 19 def full_name @full_name ||= [app_name, group_name, self[:name]].compact.join(':') end |
#group_name ⇒ Object
11 12 13 |
# File 'lib/eye/process/data.rb', line 11 def group_name self[:group] == '__default__' ? nil : self[:group] end |
#group_name_pure ⇒ Object
15 16 17 |
# File 'lib/eye/process/data.rb', line 15 def group_name_pure self[:group] end |
#logger_tag ⇒ Object
3 4 5 |
# File 'lib/eye/process/data.rb', line 3 def logger_tag full_name end |
#self_status_data(opts) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/eye/process/data.rb', line 36 def self_status_data(opts) h = { name: name, state: state, type: (self.class == Eye::ChildProcess ? :child_process : :process), resources: Eye::SystemResources.resources(pid) } if @states_history h[:state_changed_at] = @states_history.last_state_changed_at.to_i h[:state_reason] = @states_history.last_reason.to_s end h[:debug] = debug_data if opts[:debug] h[:procline] = Eye::SystemResources.args(self.pid) if opts[:procline] h[:current_command] = scheduler_current_command if scheduler_current_command h end |
#shell_string(dir = true) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/eye/process/data.rb', line 78 def shell_string(dir = true) str = '' str += "cd #{self[:working_dir]} && " if dir str += environment_string str += ' ' str += self[:start_command] str += ' &' if self[:daemonize] str end |
#status_data(opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/eye/process/data.rb', line 23 def status_data(opts = {}) p_st = self_status_data(opts) if children.present? p_st.merge(subtree: Eye::Utils::AliveArray.new(children.values).map { |c| c.status_data(opts) }) elsif self[:monitor_children] && self.up? p_st.merge(subtree: [{ name: '=loading children=' }]) else # common state p_st end end |
#sub_object?(obj) ⇒ Boolean
66 67 68 69 70 |
# File 'lib/eye/process/data.rb', line 66 def sub_object?(obj) return false if self.class == Eye::ChildProcess self.children.each { |_, child| return true if child == obj } false end |
#timers_data ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/eye/process/data.rb', line 58 def timers_data if actor = Thread.current[:celluloid_actor] actor.timers.timers.map(&:interval) end rescue [] end |