Class: Ncf::Command
- Inherits:
-
Thor
- Object
- Thor
- Ncf::Command
- Defined in:
- lib/ncf/command.rb
Instance Method Summary collapse
Instance Method Details
#desc ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ncf/command.rb', line 39 def desc validate_env if !File.exists?('exec_id.txt') abort "最初に exec を実行してください" end exec_id = File.read('exec_id.txt').chomp response = client.describe_stack(exec_id) status = response['DescribeStackResponse']['DescribeStackResult']['StackStatus'] reason = response['DescribeStackResponse']['DescribeStackResult']['StackStatusReason'] case status when 'EXECUTE_IN_PROGRESS'; puts "前回の処理が実行中です" when 'EXECUTE_COMPLETE'; puts "前回の処理が正常終了しました" else puts "前回の処理が異常終了しました (#{reason})" end end |
#exec(path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ncf/command.rb', line 9 def exec(path) validate_env if !File.exists?(path) abort "ファイルが存在しません: #{path}" end json = File.read(path) response = nil begin response = client.execute_stack(json) rescue Ncf::Client::ResponseError => e abort "ResponseError: #{e}" end exec_id = response['ExecuteStackResponse']['ExecuteStackResult']['ExecutionId'] status = nil File.write('exec_id.txt', exec_id) loop do response = client.describe_stack(exec_id) status = response['DescribeStackResponse']['DescribeStackResult']['StackStatus'] puts "処理中です" break if status != 'EXECUTE_IN_PROGRESS' sleep 5 end if status == 'EXECUTE_COMPLETE' puts "処理が正常終了しました" else puts "処理が異常終了しました" end end |