Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Pause After Service Start During Upgrade #259

Closed

Conversation

greenhut
Copy link

@greenhut greenhut commented Apr 18, 2019

Description:

Fix erroneous "Upgrade Failed" message by adding a pause after restarting the service to make sure the "pgrep -x hass" has time to get a Process ID

Related issue (if applicable): Fixes #

Checklist (Required):

If pertinent:

  • Script has validation check of the job.
  • Created/Updated documentation at /docs

@homeassistant
Copy link

Hi @greenhut,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@@ -161,6 +161,16 @@ fi
echo "Restarting Home Assistant"
systemctl restart home-assistant@homeassistant.service

echo "Waiting for Home Assistant to start"
for i in 1 2 3 4 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i appears unused. Verify it or export it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i is indeed unused,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change it to for i in 1 1 1 1 1 you can use $i as a param to sleep

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would resolve the stickler comment, but seems the tail wagging the dog a bit? Ive never written bash scripts, but think I prefer disagreeing with stickler and writing the for loop as Landrash suggested.. Again - newbie here, so whatever you guys think best.

do
sleep 1

if [ $(systemctl is-active home-assistant@homeassistant.service) == "active" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quote this to prevent word splitting.

@greenhut greenhut changed the title Update homeassistant.sh Pause After Service Start During Upgrade Apr 18, 2019
@ludeeus ludeeus added this to the 0.13.0 milestone Apr 20, 2019
@@ -161,6 +161,16 @@ fi
echo "Restarting Home Assistant"
systemctl restart home-assistant@homeassistant.service

echo "Waiting for Home Assistant to start"
for i in 1 2 3 4 5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tad cleaner since it's a more common for a common loop.

for i in {1..5}
    do
    sleep 1s
    if [ $(systemctl is-active home-assistant@homeassistant.service) == "active" ]; then
       break
    fi
done

Copy link
Author

@greenhut greenhut Apr 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - old C programmers first simple shell script. Will update.

@@ -161,6 +161,15 @@ fi
echo "Restarting Home Assistant"
systemctl restart home-assistant@homeassistant.service

echo "Waiting for Home Assistant to start"
for i in {1..5}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i appears unused. Verify it or export it.

@ludeeus
Copy link
Member

ludeeus commented May 2, 2019

@ludeeus ludeeus closed this May 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants