Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: dangerous_restart #4

Merged
merged 1 commit into from Apr 12, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions lib/runit-man/service_info/base.rb
Expand Up @@ -109,6 +109,25 @@ def all_log_file_locations
[]
end

def restart_dangerous?
changed_files_to_watch.size == 0 ? false : true
end

def changed_files_to_watch
return [] if files_to_watch.empty?

changed_files = []
files_to_watch.each do |file|
mtime = File.stat(file).mtime

if mtime > @status.started_at
changed_files << file
end
end

return changed_files
end

def send_signal(signal)
return unless supervise?

Expand Down Expand Up @@ -144,6 +163,21 @@ def urls_to_view
end
end

def files_to_watch
return [] unless File.directory?(files_to_watch_folder)

Dir.entries(files_to_watch_folder).select do |name|
File.symlink?(File.join(files_to_watch_folder, name))
end.map do |name|
File.expand_path(
File.readlink(File.join(files_to_watch_folder, name)),
files_to_watch_folder
)
end.select do |file_path|
File.file?(file_path)
end
end

def allowed_signals
return [] unless File.directory?(allowed_signals_folder)

Expand All @@ -165,6 +199,10 @@ def files_to_view_folder
File.join(active_service_folder, 'runit-man', 'files-to-view')
end

def files_to_watch_folder
File.join(active_service_folder, 'runit-man', 'files-to-watch')
end

def urls_to_view_folder
File.join(active_service_folder, 'runit-man', 'urls-to-view')
end
Expand Down
1 change: 1 addition & 0 deletions public/css/runit-man.css
Expand Up @@ -20,6 +20,7 @@ form.service-action, form.service-signal
span.inactive {color:gray;}
span.down {color:#8a1f11;}
span.run {color:#264409;}
span.danger {color:red;}

#services { text-align: center; }

Expand Down
4 changes: 3 additions & 1 deletion views/_service_info.haml
@@ -1,7 +1,9 @@
- need_second_row = !service_info.files_to_view.empty? || !service_info.urls_to_view.empty?
%tr{:class=> even_or_odd ? 'even' : 'odd'}
%td{:rowspan=> need_second_row ? 2 : 1}= h(service_info.pid)
%th{:scope=>"row"}= h(service_info.name)
%th{:scope=>"row"}
%span{:class=>service_info.restart_dangerous? ? "danger" : "ok"}
= h(service_info.name)
%td= service_info.started_at ? service_info.started_at.utc : ''
%td= service_info.uptime ? ('%.2f' % service_info.uptime) : ''
%td= stat_subst(service_info.stat)
Expand Down