freyr 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/Freyrfile CHANGED
@@ -1,3 +1,7 @@
1
1
  service :sleep do
2
+ start 'sleep 20'
3
+ end
4
+
5
+ service :sudosleep do
2
6
  start 'sudo sleep 20'
3
- end
7
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.7
1
+ 0.3.8
@@ -3,6 +3,11 @@ module Freyr
3
3
 
4
4
  def initialize(*)
5
5
  super
6
+
7
+ if options.trace?
8
+ Freyr.logger = Logger.new(STDOUT)
9
+ end
10
+
6
11
  get_services
7
12
  end
8
13
 
@@ -107,6 +112,7 @@ module Freyr
107
112
 
108
113
  unless name
109
114
  s = Service.s.find {|svc| svc.dir == Dir.pwd}
115
+ Freyr.logger.debug('getting service from directory') {"in #{Dir.pwd} found service: #{s.inspect}"}
110
116
  return group << s if s
111
117
  end
112
118
 
@@ -118,6 +124,7 @@ module Freyr
118
124
  end
119
125
  end
120
126
 
127
+ Freyr.logger.debug('getting service') {group.inspect}
121
128
  group
122
129
  end
123
130
 
@@ -6,6 +6,7 @@ module Freyr
6
6
  def start(name=nil)
7
7
  services = get_from_name(name)
8
8
  if !services.empty?
9
+ Freyr.logger.debug('starting services') {services.inspect}
9
10
  names = services.collect {|s| s.name}
10
11
  say "Starting the " << set_color(names.join(', '), :blue) << ' services'
11
12
 
@@ -23,6 +24,7 @@ module Freyr
23
24
  def stop(name=nil)
24
25
  services = get_from_name(name)
25
26
  if !services.empty?
27
+ Freyr.logger.debug('stopping services') {services.inspect}
26
28
  names = services.collect {|s| s.name}
27
29
  say "Stopping the " << set_color(names.join(', '), :blue) << ' services'
28
30
 
@@ -40,6 +42,7 @@ module Freyr
40
42
  def restart(name=nil)
41
43
  services = get_from_name(name)
42
44
  if !services.empty?
45
+ Freyr.logger.debug('restarting services') {services.inspect}
43
46
  say "Restarting the " << set_color(services.collect {|s| s.name}.join(', '), :blue) << ' services'
44
47
 
45
48
  names = services.restart
@@ -22,6 +22,8 @@ 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}
25
27
  if !services.empty?
26
28
 
27
29
  services.first.tail!(options.lines, !options['no-follow'])
data/lib/freyr/cli.rb CHANGED
@@ -11,6 +11,7 @@ module Freyr
11
11
  class_option :'config-file', :desc => 'config file to use', :type => :string
12
12
  class_option :'ignore-local', :desc => "don't use the local Freyrfile or .freyrrc", :type => :boolean, :default => false
13
13
  class_option :namespace, :type => :string, :desc => 'namespace to look in'
14
+ class_option :trace, :type => :boolean, :default => false
14
15
  map "-v" => :version
15
16
 
16
17
  desc 'version', 'displays current gem version'
data/lib/freyr/command.rb CHANGED
@@ -93,9 +93,11 @@ module Freyr
93
93
  total_time = Time.now
94
94
 
95
95
  pid = spawn(command)
96
-
96
+
97
+ Freyr.logger.debug("attempting to run command") {command.inspect}
98
+
97
99
  @pid = pid
98
-
100
+
99
101
  Process.detach(@pid)
100
102
 
101
103
  if proc_match
@@ -178,6 +180,8 @@ module Freyr
178
180
  require_admin
179
181
  sig ||= stop_sig || 'KILL'
180
182
 
183
+ Freyr.logger.debug("sending signal to process") {"Signal: #{sig}, PID: #{pid}"}
184
+
181
185
  if pid(true)
182
186
  Process.kill(sig, pid)
183
187
  end
data/lib/freyr/service.rb CHANGED
@@ -61,8 +61,11 @@ module Freyr
61
61
 
62
62
  def tail!(size = 600, follow = true)
63
63
  f = follow ? 'f' : ''
64
- Dir.chdir dir
65
- exec("tail -#{size}#{f} #{log}")
64
+ if log
65
+ cmd = "tail -#{size}#{f} #{File.join(dir||'/',log)}"
66
+ Freyr.logger.debug("tailing cmd") {cmd.inspect}
67
+ exec("tail -#{size}#{f} #{log}")
68
+ end
66
69
  end
67
70
 
68
71
  def describe
@@ -97,10 +100,13 @@ module Freyr
97
100
  def add_file f
98
101
  s
99
102
 
103
+ Freyr.logger.debug('adding file') {f}
104
+
100
105
  services = ServiceInfo.from_file(f).collect do |ser|
101
106
  raise 'Cannot have two things of the same name' if selectors.include?(ser.name)
102
107
  names |= [ser.name]
103
108
  @all_groups |= ser.groups
109
+ Freyr.logger.debug('adding service') {ser.name.inspect}
104
110
  new(ser)
105
111
  end
106
112
 
@@ -36,6 +36,7 @@ module Freyr
36
36
  end
37
37
  end
38
38
 
39
+ Freyr.logger.debug('starting service') {svc.name}
39
40
  pid = svc.start!
40
41
  names << svc.name if pid
41
42
  end
@@ -47,6 +48,7 @@ module Freyr
47
48
  def stop
48
49
  changed_names = collect {|s| s.name if s.alive?}.compact
49
50
  each do |svc|
51
+ Freyr.logger.debug('stopping service') {svc.name}
50
52
  svc.stop!
51
53
  end
52
54
 
@@ -57,6 +59,7 @@ module Freyr
57
59
  names = collect {|s| s.name}
58
60
 
59
61
  each do |s|
62
+ Freyr.logger.debug('restart service') {svc.name}
60
63
  s.restart!
61
64
  names.delete(s.name)
62
65
  end
data/lib/freyr.rb CHANGED
@@ -1,7 +1,14 @@
1
1
  require 'forwardable'
2
+ require 'logger'
2
3
 
3
4
  module Freyr
5
+ def self.logger
6
+ @logger ||= Logger.new("/dev/null")
7
+ end
4
8
 
9
+ def self.logger= logger
10
+ @logger = logger
11
+ end
5
12
  end
6
13
 
7
14
  %w{version service_group service command service_info pinger process_info}.each do |f|
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: 29
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 7
10
- version: 0.3.7
9
+ - 8
10
+ version: 0.3.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-20 00:00:00 -04:00
18
+ date: 2011-07-25 00:00:00 -04:00
19
19
  default_executable: freyr
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency