From b3c7325ee2501549c59d5bd541b64cfc83f983fe Mon Sep 17 00:00:00 2001 From: skylerto Date: Mon, 20 Aug 2018 15:24:21 -0400 Subject: [PATCH 1/2] force supervisor to run Signed-off-by: skylerto --- lib/kitchen-habitat/version.rb | 2 +- lib/kitchen/provisioner/habitat.rb | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/kitchen-habitat/version.rb b/lib/kitchen-habitat/version.rb index 51b17f3..1dac75f 100644 --- a/lib/kitchen-habitat/version.rb +++ b/lib/kitchen-habitat/version.rb @@ -1,5 +1,5 @@ module Kitchen module Habitat - VERSION = "0.10.0".freeze + VERSION = "0.11.0".freeze end end diff --git a/lib/kitchen/provisioner/habitat.rb b/lib/kitchen/provisioner/habitat.rb index 3b00698..378fd9d 100644 --- a/lib/kitchen/provisioner/habitat.rb +++ b/lib/kitchen/provisioner/habitat.rb @@ -154,6 +154,23 @@ def clean_up_previous_supervisor EOH end + def sup_run_script + <<-SCRIPT +cat > /tmp/sup-run.sh <<"END" +#!/bin/bash + +while true +do + COUNT=$(ps aux | grep hab | wc -l) + if [[ ${COUNT} -lt 2 ]] + then + sudo -E hab sup run #{supervisor_options} > /home/kitchen/nohup.out & echo $! > /tmp/run.pid + fi +done +END +SCRIPT + end + def run_package_in_background if config[:use_screen] "sudo -E screen -mdS \"#{clean_package_name}\" hab start #{package_ident} #{supervisor_options}" @@ -161,7 +178,12 @@ def run_package_in_background <<-RUN [ -f ./run.pid ] && rm -f run.pid [ -f ./nohup.out ] && rm -f nohup.out - nohup sudo -E hab sup run #{supervisor_options} & echo $! > run.pid + + #{sup_run_script} + + sudo -E chmod +x /tmp/sup-run.sh + + nohup /tmp/sup-run.sh & > sup-run.out until sudo -E hab svc status do From 43789803fb44b4b686a2cf19b586717a418c5e14 Mon Sep 17 00:00:00 2001 From: skylerto Date: Wed, 5 Sep 2018 09:18:29 -0400 Subject: [PATCH 2/2] updates to support non kitchen vms Signed-off-by: skylerto --- lib/kitchen/provisioner/habitat.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kitchen/provisioner/habitat.rb b/lib/kitchen/provisioner/habitat.rb index 378fd9d..eefb4e3 100644 --- a/lib/kitchen/provisioner/habitat.rb +++ b/lib/kitchen/provisioner/habitat.rb @@ -164,7 +164,7 @@ def sup_run_script COUNT=$(ps aux | grep hab | wc -l) if [[ ${COUNT} -lt 2 ]] then - sudo -E hab sup run #{supervisor_options} > /home/kitchen/nohup.out & echo $! > /tmp/run.pid + sudo -E hab sup run #{supervisor_options} > ~/nohup.out & echo $! > /tmp/run.pid fi done END