Announcement

Collapse
No announcement yet.

HS will not upgrade after the application was started as a service

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • John245
    replied
    Originally posted by zwolfpack View Post
    Did you restart the service?

    PS. you missed changing the path on the ExecStop directive.
    Corrected. Did even a reboot. No success
    Click image for larger version

Name:	Service4.PNG
Views:	657
Size:	81.1 KB
ID:	1495539

    ---
    John

    Leave a comment:


  • zwolfpack
    replied
    Did you restart the service?

    PS. you missed changing the path on the ExecStop directive.

    Leave a comment:


  • John245
    replied
    Originally posted by zwolfpack View Post
    Did you see my subsequent post? This unit file is the source of your issue.
    I changed my homeseer.service file to

    Click image for larger version

Name:	Service3.PNG
Views:	662
Size:	21.9 KB
ID:	1495533

    and did put the hsstop file in the root. No success.



    ---
    John

    Leave a comment:


  • zwolfpack
    replied
    Originally posted by John245 View Post
    This is my file, looks the same as avp.
    Did you see my subsequent post? This unit file is the source of your issue.

    Leave a comment:


  • John245
    replied
    Originally posted by zwolfpack View Post
    Please post contents of your systemd unit file, i.e. /etc/systemd/system/homeseer.service

    Not clear on what you mean in your 'By the way ... ' can you provide more details of what you are doing and what is the result?
    This is my file, looks the same as avp.
    Click image for larger version

Name:	service.PNG
Views:	664
Size:	12.6 KB
ID:	1495525
    ---
    John

    Leave a comment:


  • zwolfpack
    replied
    I cloned my test HS4-Linux (on rpi4) system so I could run some tests. I was successful in updating from 4.2.0.0 to beta 4.2.0.5, and back again. Ran the cycle three times to be sure.

    I then substituted in @avpman's unit file, and things went sideways fast. After some thought it came back that, under systemd, default behavior is as soon as the main process terminates, systemd immediately clobbers all child processes. So when the HSConsole process ends, the update.sh script gets clobbered before it can do it's thing. There are some additional directives needed in the unit file to make this work as we want.

    Below is my unit file (homeseer.service), with "/usr/local/HomeSeer" as the HS root. After editing files in /etc/systemd/system, you want to run
    Code:
    sudo systemctl daemon-reload
    to prevent systemd from bellyaching about changed unit files.

    Code:
    [Unit]
    Description=HomeSeer Home Automation
    Documentation=https://homeseer.com/support-home/
    After=network-online.target remote-fs.target time-sync.target
    Before=multi-user.target
    
    [Service]
    WorkingDirectory=/usr/local/HomeSeer
    ExecStart=/usr/bin/mono HSConsole.exe --log
    SyslogIdentifier=HSConsole
    StandardOutput=null
    Restart=on-failure
    RestartSec=30
    KillMode=none
    TimeoutStopSec=300
    ExecStop=/usr/local/HomeSeer/hsstop.sh
    
    [Install]
    WantedBy=multi-user.target
    Here is the hsstop.sh, which lives in the HS root. Presume this is similar to @avpman's "stop_homeseer.sh". Remember to make this executable.
    Code:
    #!/bin/bash
    # hsstop.sh - stop the HS application
    # supports: systemd service shutdown
    
    # import login credentials used to login to web server
    # these are ignored if password not required
    inifile=$(dirname $0)/Config/$(basename $0 .sh).ini
    login=
    test -r $inifile && . $inifile
    
    # extract web server port from settings.ini
    hsroot=$(dirname $0)  # where this script lives
    webport=$(awk -F= '\
    {
        gsub("\015", "") # remove CR character
        if ($1 == "gWebSvrPort") print $2
    }
    ' $hsroot/Config/settings.ini)
    
    # send application shutdown command
    for i in $(seq 1 5)
    do
        curl -f -s -o /dev/null ${login:+-u} $login --data 'ConfirmShutdownhs=Yes' "http://localhost:$webport/LinuxTools"
        rc=$?
        test $rc -eq 0 && break
        curl -f -s -o /dev/null ${login:+-u} $login --data 'action=shutdown_hs' "http://localhost:$webport/system.html"
        rc=$?
        test $rc -eq 0 && break
        sleep 2
    done
    
    killmain()
    {
        test -n "$MAINPID" && kill -0 $MAINPID && kill $MAINPID
    }
    
    trap killmain EXIT
    
    # if curl cmd unsuccessful, terminate main process
    test $rc -ne 0 && killmain
    
    # wait until all HomeSeer mono processes terminate, with timeout
    maxwait=300
    polltime=5
    mono=$(which mono) || exit
    for (( t=0; t<$maxwait; t+=$polltime ))
    do
        pgrep -afi $mono.'*'\(HSConsole\|HSPI_\) || break
        sleep $polltime
    done

    Leave a comment:


  • avpman
    replied
    Another user here with the same problem. Here is my homeseer.service file contents:

    [Unit]
    Description=HomeSeer HS4 Home Automation Server
    After=network.target

    [Service]
    WorkingDirectory=/usr/local/HomeSeer
    ExecStart=/usr/bin/mono /usr/local/HomeSeer/HSConsole.exe --log
    ExecStop=/usr/local/HomeSeer/stop_homeseer.sh
    Restart=on-failure
    TimeoutStopSec=90

    [Install]
    WantedBy=multi-user.target

    Leave a comment:


  • zwolfpack
    replied
    Please post contents of your systemd unit file, i.e. /etc/systemd/system/homeseer.service

    Not clear on what you mean in your 'By the way ... ' can you provide more details of what you are doing and what is the result?

    Leave a comment:


  • HS will not upgrade after the application was started as a service

    zwolfpack you requested SteveW in this post https://forums.homeseer.com/forum/hs...99#post1494999 to start a new thread. As I did populate the hypothesis I will starting this thread.

    I found the root cause for my system (during extensive testing 0n 4.2.0.0). Although I have no idea to fix.

    I repeated the steps in this post

    https://forums.homeseer.com/forum/ho...01#post1491401

    also on 4.2.0.5 with identical results.

    So the behavior of situation 1 and 2 differs

    1. Upgrade after starting HomeSeer usig ./go PASS
    2. Upgrade after starting Homeseer as a service FAIL (starting as a service following these directions: https://forums.homeseer.com/forum/ho...45#post1306645)

    By the way In case of situation 1 when I do a reinstall of HomeSeer after the first successful upgrade it will alos fail. So my hypothesis is that during the upgrade process the instance is rebooted. In case you can confirm this we will know the root cause for sure.

    Any idea how to fix?

    ---
    John
Working...
X