runit-man 1.4.7 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/runit-man/app.rb +8 -0
- data/lib/runit-man/service_info.rb +7 -7
- metadata +34 -6
data/lib/runit-man/app.rb
CHANGED
@@ -87,6 +87,14 @@ class RunitMan < Sinatra::Base
|
|
87
87
|
puts "#{addr} - - [#{Time.now}] \"Do #{text} on #{name}\""
|
88
88
|
end
|
89
89
|
|
90
|
+
post '/:name/signal/:signal' do |name, signal|
|
91
|
+
srv = ServiceInfo[name]
|
92
|
+
return not_found if srv.nil?
|
93
|
+
srv.send_signal(signal)
|
94
|
+
log_action(name, "send signal \"#{signal}\"")
|
95
|
+
''
|
96
|
+
end
|
97
|
+
|
90
98
|
post '/:name/:action' do |name, action|
|
91
99
|
srv = ServiceInfo[name]
|
92
100
|
action = "#{action}!".to_sym
|
@@ -37,11 +37,11 @@ class ServiceInfo
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def up!
|
40
|
-
send_signal
|
40
|
+
send_signal :u
|
41
41
|
end
|
42
42
|
|
43
43
|
def down!
|
44
|
-
send_signal
|
44
|
+
send_signal :d
|
45
45
|
end
|
46
46
|
|
47
47
|
def switch_down!
|
@@ -72,6 +72,11 @@ class ServiceInfo
|
|
72
72
|
File.expand_path(rel_path, log_run_folder)
|
73
73
|
end
|
74
74
|
|
75
|
+
def send_signal(signal)
|
76
|
+
return unless supervise?
|
77
|
+
File.open(File.join(supervise_folder, 'control'), 'w') { |f| f.print signal.to_s }
|
78
|
+
end
|
79
|
+
|
75
80
|
private
|
76
81
|
def inactive_service_folder
|
77
82
|
File.join(RunitMan.all_services_directory, name)
|
@@ -104,11 +109,6 @@ private
|
|
104
109
|
r.empty? ? nil : r
|
105
110
|
end
|
106
111
|
|
107
|
-
def send_signal!(signal)
|
108
|
-
return unless supervise?
|
109
|
-
File.open(File.join(supervise_folder, 'control'), 'w') { |f| f.print signal.to_s }
|
110
|
-
end
|
111
|
-
|
112
112
|
class << self
|
113
113
|
def all
|
114
114
|
all_service_names.sort.map do |name|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 1.4.
|
8
|
+
- 8
|
9
|
+
version: 1.4.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Akzhan Abdulin
|
@@ -115,11 +115,39 @@ dependencies:
|
|
115
115
|
version: "0"
|
116
116
|
type: :development
|
117
117
|
version_requirements: *id008
|
118
|
-
description:
|
119
|
-
|
118
|
+
description: |+
|
119
|
+
h2. DESCRIPTION
|
120
|
+
|
121
|
+
Simple "runit":http://smarden.org/runit/ web management tool with i18n.
|
122
|
+
|
123
|
+
Server will run by @runit-man@ script. Take a note that @runit-man@ must have privileges like @runsvdir@ ones.
|
124
|
+
|
125
|
+
h2. REST API
|
126
|
+
|
127
|
+
h3. Get state
|
128
|
+
|
129
|
+
You can read current state of services in "JSON format":http://www.json.org/ using
|
130
|
+
@GET /services.json@
|
131
|
+
|
132
|
+
h3. Management
|
133
|
+
|
134
|
+
You can manage your services using
|
135
|
+
@POST /service name/command@
|
136
|
+
|
137
|
+
Supported commands: up, down, restart, switch_up (activates service), switch_down (deactivates service).
|
138
|
+
|
139
|
+
You can also send any signal to service using
|
140
|
+
@POST /service name/signal/<signal>@
|
141
|
+
|
142
|
+
h3. Read logs
|
143
|
+
|
144
|
+
You can read tail of service log using
|
145
|
+
@GET /service name/log/count_of_lines.txt@
|
146
|
+
|
147
|
+
Note that to use this feature You must do logging using
|
148
|
+
@svlogd options log_directory_location@
|
149
|
+
|
120
150
|
|
121
|
-
Server will run by runit-man script.
|
122
|
-
|
123
151
|
email: akzhan.abdulin@gmail.com
|
124
152
|
executables:
|
125
153
|
- runit-man
|