runit-man 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/i18n/en.yml CHANGED
@@ -26,6 +26,7 @@ runit:
26
26
  down: <span class="down">down<span>
27
27
  finish: <span class="down">finish<span>
28
28
  run: <span class="run">run<span>
29
+ up: <span class="run">up<span>
29
30
  actions:
30
31
  start: Start
31
32
  stop: Stop
data/i18n/ru.yml CHANGED
@@ -26,6 +26,7 @@ runit:
26
26
  down: <span class="down">остановлен</span>
27
27
  finish: <span class="down">останавливается</span>
28
28
  run: <span class="run">работает</span>
29
+ up: <span class="run">поднятие</span>
29
30
  got: получен
30
31
  want: ожидается
31
32
  actions:
@@ -36,8 +36,7 @@ class ServiceInfo
36
36
  end
37
37
 
38
38
  def stat
39
- r = data_from_file(File.join(supervise_folder, 'stat'))
40
- r ? r : 'inactive'
39
+ @status.inactive? ? 'inactive' : @status.to_s
41
40
  end
42
41
 
43
42
  def active?
@@ -227,7 +226,6 @@ private
227
226
  def all_service_names
228
227
  (active_service_names + inactive_service_names)
229
228
  end
230
-
231
229
  end
232
230
  end
233
231
 
@@ -1,52 +1,78 @@
1
- class ServiceStatus
2
- def initialize(data)
3
- # status in daemontools supervise format
4
- # look at runit's sv.c for details
5
- data = !data.nil? && data.length == 20 ? data : nil
6
- @raw = data.nil? ? nil : data.unpack('NNxxxxVxa1CC')
7
- end
8
-
9
- def down?
10
- status_byte == 0
11
- end
12
-
13
- def run?
14
- status_byte == 1
15
- end
16
-
17
- def finish?
18
- status_byte == 2
19
- end
20
-
21
- def pid
22
- @pid ||= down? ? nil : @raw[2]
23
- end
24
-
25
- def started_at
26
- # from TAI to Unix
27
- @started_at ||= @raw ? Time.at((@raw[0] << 32) + @raw[1] - 4611686018427387914) : nil
28
- end
29
-
30
- def uptime
31
- @uptime ||= down? ? nil : Time.now - started_at
32
- end
33
-
34
- def want_up?
35
- @raw && !pid && @raw[3] == 'u'
36
- end
37
-
38
- def want_down?
39
- pid && @raw[3] == 'd'
40
- end
41
-
42
- def got_term?
43
- pid && @raw[4] != 0
44
- end
45
-
46
- private
47
- def status_byte
48
- @status_byte ||= @raw ? @raw[5] : 0
49
- end
50
-
51
- end
52
-
1
+ class ServiceStatus
2
+ STATUS_SIZE = 20
3
+ # state
4
+ S_DOWN = 0
5
+ S_RUN = 1
6
+ S_FINISH = 2
7
+
8
+ def initialize(data)
9
+ # status in daemontools supervise format
10
+ # look at runit's sv.c for details
11
+ data = (!data.nil? && data.length == STATUS_SIZE) ? data : nil
12
+ @raw = data.nil? ? nil : data.unpack('NNxxxxVxa1CC')
13
+ end
14
+
15
+ def inactive?
16
+ @raw.nil?
17
+ end
18
+
19
+ def down?
20
+ status_byte == S_DOWN
21
+ end
22
+
23
+ def run?
24
+ status_byte == S_RUN
25
+ end
26
+
27
+ def finish?
28
+ status_byte == S_FINISH
29
+ end
30
+
31
+ def pid
32
+ @pid ||= down? ? nil : @raw[2]
33
+ end
34
+
35
+ def started_at
36
+ # from TAI to Unix
37
+ @started_at ||= @raw ? Time.at((@raw[0] << 32) + @raw[1] - 4611686018427387914) : nil
38
+ end
39
+
40
+ def uptime
41
+ @uptime ||= down? ? nil : Time.now - started_at
42
+ end
43
+
44
+ def want_up?
45
+ @raw && !pid && @raw[3] == 'u'
46
+ end
47
+
48
+ def want_down?
49
+ pid && @raw[3] == 'd'
50
+ end
51
+
52
+ def got_term?
53
+ pid && @raw[4] != 0
54
+ end
55
+
56
+ def to_s
57
+ # try to mimics stat behaviour to minimize readings
58
+ result = status_string
59
+ result += ', got TERM' if got_term?
60
+ result += ', want down' if want_down?
61
+ result += ', want up' if want_up?
62
+ result
63
+ end
64
+
65
+ private
66
+ def status_byte
67
+ @status_byte ||= @raw ? @raw[5] : 0
68
+ end
69
+
70
+ def status_string
71
+ case status_byte
72
+ when S_DOWN then 'down'
73
+ when S_RUN then 'run'
74
+ when S_FINISH then 'finish'
75
+ end
76
+ end
77
+ end
78
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 8
8
- - 3
9
- version: 1.8.3
8
+ - 4
9
+ version: 1.8.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Akzhan Abdulin