rexec 1.5.0 → 1.5.1

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/Gemfile CHANGED
@@ -2,3 +2,4 @@
2
2
  source "https://rubygems.org"
3
3
 
4
4
  gem "rake"
5
+ gem "rainbow"
@@ -53,7 +53,7 @@ module RExec
53
53
 
54
54
  # The directory the daemon will run in.
55
55
  def self.working_directory
56
- File.join(@@base_directory, daemon_name)
56
+ @@base_directory
57
57
  end
58
58
 
59
59
  # Return the directory to store log files in.
@@ -63,7 +63,7 @@ module RExec
63
63
 
64
64
  # Standard log file for stdout and stderr.
65
65
  def self.log_file_path
66
- File.join(log_directory, "daemon.log")
66
+ File.join(log_directory, "#{daemon_name}.log")
67
67
  end
68
68
 
69
69
  # Runtime data directory for the daemon.
@@ -73,7 +73,7 @@ module RExec
73
73
 
74
74
  # Standard location of process pid file.
75
75
  def self.process_file_path
76
- File.join(runtime_directory, "daemon.pid")
76
+ File.join(runtime_directory, "#{daemon_name}.pid")
77
77
  end
78
78
 
79
79
  # Mark the output log.
@@ -87,7 +87,7 @@ module RExec
87
87
  def self.tail_log(output)
88
88
  lines = []
89
89
 
90
- File.open(error_log_path, "r") do |log_file|
90
+ File.open(log_file_path, "r") do |log_file|
91
91
  log_file.seek_end
92
92
 
93
93
  log_file.reverse_each_line do |line|
@@ -103,10 +103,10 @@ module RExec
103
103
 
104
104
  # Check the last few lines of the log file to find out if the daemon crashed.
105
105
  def self.crashed?
106
- File.open(error_log_path, "r") do |log_file|
106
+ File.open(log_file_path, "r") do |log_file|
107
107
  log_file.seek_end
108
108
 
109
- count = 2
109
+ count = 3
110
110
  log_file.reverse_each_line do |line|
111
111
  return true if line.match("=== Daemon Crashed")
112
112
 
@@ -21,6 +21,8 @@
21
21
  require 'rexec/daemon/process_file'
22
22
  require 'rexec/task'
23
23
 
24
+ require 'rainbow'
25
+
24
26
  module RExec
25
27
  module Daemon
26
28
  # Daemon startup timeout
@@ -53,16 +55,16 @@ module RExec
53
55
 
54
56
  # This function starts the supplied daemon
55
57
  def self.start(daemon)
56
- puts "Starting daemon..."
58
+ puts "Starting daemon...".color(:blue)
57
59
 
58
60
  case ProcessFile.status(daemon)
59
61
  when :running
60
- $stderr.puts "Daemon already running!"
62
+ $stderr.puts "Daemon already running!".color(:blue)
61
63
  return
62
64
  when :stopped
63
65
  # We are good to go...
64
66
  else
65
- $stderr.puts "Daemon in unknown state! Will clear previous state and continue."
67
+ $stderr.puts "Daemon in unknown state! Will clear previous state and continue.".color(:red)
66
68
  status(daemon)
67
69
  ProcessFile.clear(daemon)
68
70
  end
@@ -125,14 +127,14 @@ module RExec
125
127
  end
126
128
  end
127
129
 
128
- puts "Waiting for daemon to start..."
130
+ puts "Waiting for daemon to start...".color(:blue)
129
131
  sleep 0.1
130
132
  timer = TIMEOUT
131
133
  pid = ProcessFile.recall(daemon)
132
134
 
133
135
  while pid == nil and timer > 0
134
136
  # Wait a moment for the forking to finish...
135
- puts "Waiting for daemon to start (#{timer}/#{TIMEOUT})"
137
+ puts "Waiting for daemon to start (#{timer}/#{TIMEOUT})".color(:blue)
136
138
  sleep 1
137
139
 
138
140
  # If the daemon has crashed, it is never going to start...
@@ -148,28 +150,29 @@ module RExec
148
150
  def self.status(daemon)
149
151
  case ProcessFile.status(daemon)
150
152
  when :running
151
- puts "Daemon status: running pid=#{ProcessFile.recall(daemon)}"
153
+ puts "Daemon status: running pid=#{ProcessFile.recall(daemon)}".color(:green)
152
154
  when :unknown
153
155
  if daemon.crashed?
154
- puts "Daemon status: crashed"
156
+ puts "Daemon status: crashed".color(:red)
155
157
 
156
158
  $stdout.flush
157
- daemon.tail_error_log($stderr)
159
+ $stderr.puts "Dumping daemon crash log:".color(:red)
160
+ daemon.tail_log($stderr)
158
161
  else
159
- puts "Daemon status: unknown"
162
+ puts "Daemon status: unknown".color(:red)
160
163
  end
161
164
  when :stopped
162
- puts "Daemon status: stopped"
165
+ puts "Daemon status: stopped".color(:blue)
163
166
  end
164
167
  end
165
168
 
166
169
  # Stops the daemon process.
167
170
  def self.stop(daemon)
168
- puts "Stopping daemon..."
171
+ puts "Stopping daemon...".color(:blue)
169
172
 
170
173
  # Check if the pid file exists...
171
174
  unless File.file?(daemon.process_file_path)
172
- puts "Pid file not found. Is the daemon running?"
175
+ puts "Pid file not found. Is the daemon running?".color(:red)
173
176
  return
174
177
  end
175
178
 
@@ -177,7 +180,7 @@ module RExec
177
180
 
178
181
  # Check if the daemon is already stopped...
179
182
  unless ProcessFile.running(daemon)
180
- puts "Pid #{pid} is not running. Has daemon crashed?"
183
+ puts "Pid #{pid} is not running. Has daemon crashed?".color(:red)
181
184
  return
182
185
  end
183
186
 
@@ -191,7 +194,7 @@ module RExec
191
194
  while ProcessFile.running(daemon) and attempts > 0
192
195
  sig = (attempts < 2) ? "KILL" : "TERM"
193
196
 
194
- puts "Sending #{sig} to pid #{pid}..."
197
+ puts "Sending #{sig} to pid #{pid}...".color(:red)
195
198
  Process.kill(sig, pid)
196
199
 
197
200
  sleep 1
@@ -200,7 +203,7 @@ module RExec
200
203
 
201
204
  # If after doing our best the daemon is still running (pretty odd)...
202
205
  if ProcessFile.running(daemon)
203
- puts "Daemon appears to be still running!"
206
+ puts "Daemon appears to be still running!".color(:red)
204
207
  return
205
208
  end
206
209
 
data/lib/rexec/version.rb CHANGED
@@ -22,7 +22,7 @@ module RExec
22
22
  module VERSION
23
23
  MAJOR = 1
24
24
  MINOR = 5
25
- TINY = 0
25
+ TINY = 1
26
26
 
27
27
  STRING = [MAJOR, MINOR, TINY].join('.')
28
28
  end
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  # This script is used to test actual remote connections
24
- # e.g. ./test_remote.rb "ssh haru.oriontransfer.org"
24
+ # e.g. ./test_remote_server.rb "ssh haru.oriontransfer.org"
25
25
 
26
26
  require 'helper'
27
27
 
@@ -65,4 +65,3 @@ class RemoteServerTest < Test::Unit::TestCase
65
65
  conn.stop
66
66
  end
67
67
  end
68
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-15 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rainbow
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description:
15
31
  email: samuel@oriontransfer.org
16
32
  executables:
@@ -58,6 +74,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
74
  - - ! '>='
59
75
  - !ruby/object:Gem::Version
60
76
  version: '0'
77
+ segments:
78
+ - 0
79
+ hash: 3629144491147234128
61
80
  required_rubygems_version: !ruby/object:Gem::Requirement
62
81
  none: false
63
82
  requirements: