Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added more diagnostic info in node

  • Loading branch information...
commit 6f9a45ac45bafe25800cb74744401127c3e37994 1 parent c63815f
@exceedhl authored
Showing with 27 additions and 11 deletions.
  1. +1 −1  Gemfile.lock
  2. +25 −9 lib/toft/node.rb
  3. +1 −1  lib/toft/version.rb
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- toft (0.0.6)
+ toft (0.0.8)
net-ssh
GEM
View
34 lib/toft/node.rb
@@ -36,7 +36,7 @@ class Node
-----END RSA PRIVATE KEY-----
EOF
- TIMOUT_IN_SECONDS = 60
+ TIMEOUT_IN_SECONDS = 120
TRY_INTERVAL = 0.5
include Observable
@@ -65,6 +65,7 @@ def exists?
end
def start
+ puts "Starting host node..."
cmd "lxc-start -n #{@hostname} -d" # system + sudo lxc-start does not work on centos-6, but back-quote does(no clue on why)
cmd! "lxc-wait -n #{@hostname} -s RUNNING"
wait_ssh_ready
@@ -149,31 +150,46 @@ def rootfs
end
def wait_sshd_running
- while true
+ wait_for do
netstat = cmd("lxc-netstat --name #{@hostname} -ta")
return if netstat =~ /ssh/
end
end
def wait_remote_host_reachable
- max_try = TIMOUT_IN_SECONDS / TRY_INTERVAL
- try = 0
- while try < max_try
+ wait_for do
begin
- break if Ping.pingecho fqdn, 0.1
+ return if Ping.pingecho fqdn, 0.1
rescue Exception
# fix the strange pingcho exception
end
- sleep TRY_INTERVAL
- try += 1
end
raise RuntimeError, "Remote machine not responding." if try >= max_try
end
+ def wait_for
+ return if !block_given?
+ max_try = TIMEOUT_IN_SECONDS / TRY_INTERVAL
+ try = 0
+ while try < max_try
+ output_progress
+ yield
+ sleep TRY_INTERVAL
+ try += 1
+ end
+ end
+
+ def output_progress
+ print "."
+ STDOUT.flush
+ end
+
def wait_ssh_ready
+ print "Waiting for host ssdh ready"
wait_sshd_running
+ print "\nWaiting for host to be reachable"
wait_remote_host_reachable
- puts "SSH connection on '#{@hostname}/#{@ip}' is ready..."
+ puts "\nSSH connection on '#{@hostname}/#{@ip}' is ready."
end
def generate_lxc_config
View
2  lib/toft/version.rb
@@ -1,3 +1,3 @@
module Toft
- VERSION = "0.0.6"
+ VERSION = "0.0.8"
end

0 comments on commit 6f9a45a

Please sign in to comment.
Something went wrong with that request. Please try again.