Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force supervisor to run #29

Merged
merged 3 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/kitchen-habitat/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Kitchen
module Habitat
VERSION = "0.10.0".freeze
VERSION = "0.11.0".freeze
end
end
24 changes: 23 additions & 1 deletion lib/kitchen/provisioner/habitat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,36 @@ 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} > ~/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}"
else
<<-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
Expand Down