freyr 0.3.8 → 0.3.9

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -22,10 +22,9 @@ module Freyr
22
22
  method_option :'no-follow', :type => :boolean, :default => false, :desc => 'Disable auto follow, just print tail and exit'
23
23
  def tail(name=nil)
24
24
  services = get_from_name(name)
25
- Freyr.logger.debug('tail args') {"Lines: #{options.lines}, following: #{!options['no-follow']}"}
26
- Freyr.logger.debug('tailing service') {services.first.inspect}
27
25
  if !services.empty?
28
-
26
+ Freyr.logger.debug('tail args') {"Lines: #{options.lines}, following: #{!options['no-follow']}"}
27
+ Freyr.logger.debug('tailing service') {services.first.inspect}
29
28
  services.first.tail!(options.lines, !options['no-follow'])
30
29
  else
31
30
  say "Can't find the #{name} service", :red
data/lib/freyr/service.rb CHANGED
@@ -31,8 +31,11 @@ module Freyr
31
31
  end
32
32
 
33
33
  def start!
34
- return unless start_command
35
- command.run! unless alive?
34
+ if start_command
35
+ command.run! unless alive?
36
+ else
37
+ error("no start_command")
38
+ end
36
39
  end
37
40
 
38
41
  def stop!
@@ -59,15 +62,26 @@ module Freyr
59
62
  end
60
63
  end
61
64
 
65
+ def read_log
66
+ @service_info.log || @service_info.read_log
67
+ end
68
+
62
69
  def tail!(size = 600, follow = true)
63
70
  f = follow ? 'f' : ''
64
- if log
65
- cmd = "tail -#{size}#{f} #{File.join(dir||'/',log)}"
71
+ if read_log
72
+ cmd = "tail -#{size}#{f} #{File.join(dir||'/',read_log)}"
66
73
  Freyr.logger.debug("tailing cmd") {cmd.inspect}
67
- exec("tail -#{size}#{f} #{log}")
74
+ exec(cmd)
75
+ else
76
+ error("no logfile found")
68
77
  end
69
78
  end
70
79
 
80
+ def error *args, &blk
81
+ Freyr.logger.error(*args,&blk)
82
+ Freyr.logger.debug("service info for service #{self}") {@service_info.inspect}
83
+ end
84
+
71
85
  def describe
72
86
  %Q{#{name}(#{groups.join(',')}) - #{start_command}}
73
87
  end
@@ -79,6 +93,10 @@ module Freyr
79
93
  also.find {|a| a.to_s == n}
80
94
  end
81
95
 
96
+ def inspect
97
+ %Q{#<Freyr::Service #{name} #{start_command.inspect}>}
98
+ end
99
+
82
100
  class << self
83
101
 
84
102
  def s
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freyr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 8
10
- version: 0.3.8
9
+ - 9
10
+ version: 0.3.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas