Announcement

Collapse
No announcement yet.

HS4 4.0.8.0 on Ubuntu Server 20.04 - Startup Service Not Working

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

    HS4 4.0.8.0 on Ubuntu Server 20.04 - Startup Service Not Working

    I have successfully installed HS4 4.0.8.0 on my Ubuntu Server 20.04 VM.

    If I start HS from the shell with the ./go script everything works fine I can access HS from the Web GUI.

    However, if I create a service for HSConsole.exe and then start the service everything loads as per the log file (Startup.log) normally but I cannot access the web GUI.

    Here is my service Unit file:

    Code:
    #/etc/systemd/system/hs4.service
    
    [Unit]
    Description=HS4 Automation Server
    After=network.target
    StartLimitIntervalSec=0
    [Service]
    Type=simple
    Restart=always
    RestartSec=1
    User=root
    ExecStart=/usr/bin/mono /root/homeseer/HSConsole.exe --log
    
    [Install]
    WantedBy=multi-user.target
    I then activate and start the service:

    Code:
    systemctl enable hs4
    systemctl start hs4
    Everything looks happy...

    Code:
    # systemctl status hs4
    ● hs4.service - HS4 Automation Server
    Loaded: loaded (/etc/systemd/system/hs4.service; enabled; vendor preset: enabled)
    Active: active (running) since Mon 2020-06-15 08:27:43 EDT; 6s ago
    Main PID: 2099 ((System)_15-Jun)
    Tasks: 29 (limit: 9451)
    Memory: 38.8M
    CGroup: /system.slice/hs4.service
    └─2099 /usr/bin/mono /root/homeseer/HSConsole.exe --log
    
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:2896:[Web Server]->Local IP address is: 192.168.0.225
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:3387:[Web Server]->Web Server started on port 724
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:3828:[Startup]->Start automation engine...
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:3924:[Startup]->Initializing Speaker Client Interface
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:4593:[Speech]->Listening for remote speaker connections on port 10401
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:4914:[Database]->Opening (Mode=Read/Write) up HomeSeer Energy database /root/homeseer/Data/Energy/Energy.hsd
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:6888:[Startup]->Updater services starting...
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:6936:[Startup]->Starting Find service...
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:7781:[Info]->Remote plug-in API interface started on port 10400
    Jun 15 08:27:49 vm mono[2099]: 08:27:49:7838:[Startup]->Checking for available plug-ins
    Here is the Startup log running as service:

    Code:
    06/15/2020 08:42:47 HomeSeer~!~Database~!~Opening (Mode=Read Only) up HomeSeer LOG database /root/homeseer/Logs/HomeSeerLog.hsd
    06/15/2020 08:42:47 HomeSeer~!~Startup~!~Loading Settings
    06/15/2020 08:42:47 HomeSeer~!~Startup~!~Settings Loaded.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~*************************************** *****************************************
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~ HomeSeer version 4.0.8.0 Edition: HS4 Pro Starting Now
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~*************************************** *****************************************
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~Creating Class Objects...
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~COM port classes started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~Application interface class started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~Web server class started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~E-Mail SEND class started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~E-Mail RECEIVE class started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~Plug-In Interface class started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~Local voice recognition class started.
    06/15/2020 08:42:49 HomeSeer~!~Startup~!~Loading configuration file ...
    06/15/2020 08:42:50 HomeSeer~!~Database~!~Loaded 1 Devices.
    06/15/2020 08:42:50 HomeSeer~!~3~!~Unable to load event groups config file, trying backup
    06/15/2020 08:42:50 HomeSeer~!~4~!~Unable to read event groups from normal or backup file!
    06/15/2020 08:42:50 HomeSeer~!~3~!~Unable to load events config file, trying backup
    06/15/2020 08:42:50 HomeSeer~!~4~!~Unable to load events from normal or backup file!
    06/15/2020 08:42:50 HomeSeer~!~3~!~Unable to load counters config file, trying backup
    06/15/2020 08:42:50 HomeSeer~!~4~!~Unable to load counters from normal or backup file!
    06/15/2020 08:42:50 HomeSeer~!~3~!~Unable to load timers config file, trying backup
    06/15/2020 08:42:50 HomeSeer~!~4~!~Unable to load timers from normal or backup file!
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~HomeSeer version is: 4.0.8.0
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~Creating Speaker Client Interface Object...
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~This version of HomeSeer is registered as a HS4PRO version.
    06/15/2020 08:42:50 HomeSeer~!~Web Server~!~Local IP address is: 192.168.0.225
    06/15/2020 08:42:50 HomeSeer~!~Web Server~!~Web Server started on port 724
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~Start automation engine...
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~Initializing Speaker Client Interface
    06/15/2020 08:42:50 HomeSeer~!~Speech~!~Listening for remote speaker connections on port 10401
    06/15/2020 08:42:50 HomeSeer~!~Database~!~Opening (Mode=Read/Write) up HomeSeer Energy database /root/homeseer/Data/Energy/Energy.hsd
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~Updater services starting...
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~Starting Find service...
    06/15/2020 08:42:50 HomeSeer~!~Info~!~Remote plug-in API interface started on port 10400
    06/15/2020 08:42:50 HomeSeer~!~Startup~!~Checking for available plug-ins
    06/15/2020 08:42:52 HomeSeer~!~Web Server~!~Web Server authorized local login successful from: 192.168.0.161 User: default
    06/15/2020 08:42:52 HomeSeer~!~Plug-In~!~Found plug-in: Z-Wave, version: 3.0.2.0
    06/15/2020 08:42:52 HomeSeer~!~Startup~!~Initializing Plug-Ins
    06/15/2020 08:42:54 HomeSeer~!~Info~!~Plugin Z-Wave has connected. IP:127.0.0.1:50968
    06/15/2020 08:42:54 HomeSeer~!~Starting Plug-In~!~Initializing plugin Z-Wave ...
    06/15/2020 08:42:54 Legacy-Plugin~!~Z-Wave~!~InitIO called, plug-in version 3.0.2.0 is being initialized...
    06/15/2020 08:42:55 Legacy-Plugin~!~Z-Wave~!~Database: Opening (Mode=Read Only) up HomeSeer database /root/homeseer/Data/Z-Wave/Z-Wave2.db
    06/15/2020 08:42:55 HomeSeer~!~Starting Plug-In~!~Plugin Z-Wave started successfully in 1213 milliseconds
    06/15/2020 08:42:55 Legacy-Plugin~!~Z-Wave~!~0 event actions were loaded from HomeSeer.
    06/15/2020 08:42:55 Legacy-Plugin~!~Z-Wave~!~0 event triggers were loaded from HomeSeer.
    06/15/2020 08:42:55 HomeSeer~!~Starting Plug-In~!~Z-Wave loaded in 3012 milliseconds
    06/15/2020 08:42:55 HomeSeer~!~Plug-In~!~Finished initializing plug-in Z-Wave
    06/15/2020 08:42:55 HomeSeer~!~HSTouch Server~!~Server started on port 10200
    06/15/2020 08:42:55 HomeSeer~!~Startup~!~HStouch server started, waiting for clients to connect.
    06/15/2020 08:42:55 Legacy-Plugin~!~Z-Wave~!~465 Simple AV Control Command Class Control Commands have been loaded successfully.
    Here is the Log when starting from command line:

    Code:
    root@vm:~/homeseer# ./go
    HomeSeer Linux starting...
    08:40:50:5191:[Database]->Opening (Mode=Read Only) up HomeSeer LOG database /root/homeseer/Logs/HomeSeerLog.hsd
    08:40:51:5305:[Startup]->Loading Settings
    08:40:51:9008:[Startup]->Settings Loaded.
    08:40:53:5454:[Startup]->
    08:40:53:5468:[Startup]->*********************************************************** *********************
    08:40:53:5503:[Startup]-> HomeSeer version 4.0.8.0 Edition: HS4 Pro Starting Now
    08:40:53:5518:[Startup]->*********************************************************** *********************
    08:40:53:5540:[Startup]->
    08:40:53:6059:[Startup]->Creating Class Objects...
    08:40:53:6120:[Startup]->COM port classes started.
    08:40:53:6235:[Startup]->Application interface class started.
    08:40:53:6360:[Startup]->Web server class started.
    08:40:53:6687:[Startup]->E-Mail SEND class started.
    08:40:53:6895:[Startup]->E-Mail RECEIVE class started.
    08:40:53:7059:[Startup]->Plug-In Interface class started.
    08:40:53:7250:[Startup]->Local voice recognition class started.
    08:40:53:7400:[Startup]->Loading configuration file ...
    08:40:54:5516:[Database]->Loaded 1 Devices.
    08:40:54:5881:[3]->Unable to load event groups config file, trying backup
    08:40:54:5902:[4]->Unable to read event groups from normal or backup file!
    08:40:54:5971:[3]->Unable to load events config file, trying backup
    08:40:54:6089:[4]->Unable to load events from normal or backup file!
    08:40:54:6117:[3]->Unable to load counters config file, trying backup
    08:40:54:6134:[4]->Unable to load counters from normal or backup file!
    08:40:54:6165:[3]->Unable to load timers config file, trying backup
    08:40:54:6180:[4]->Unable to load timers from normal or backup file!
    08:40:54:6585:[Startup]->HomeSeer version is: 4.0.8.0
    08:40:54:6607:[Startup]->Creating Speaker Client Interface Object...
    08:40:54:6696:[Startup]->This version of HomeSeer is registered as a HS4PRO version.
    08:40:54:7128:[Web Server]->Local IP address is: 192.168.0.225
    08:40:54:7262:[Web Server]->Web Server started on port 724
    08:40:54:7777:[Startup]->Start automation engine...
    08:40:54:7896:[Startup]->Initializing Speaker Client Interface
    08:40:54:8523:[Speech]->Listening for remote speaker connections on port 10401
    08:40:54:8753:[Database]->Opening (Mode=Read/Write) up HomeSeer Energy database /root/homeseer/Data/Energy/Energy.hsd
    08:40:55:0380:[Startup]->Updater services starting...
    08:40:55:0428:[Startup]->Starting Find service...
    08:40:55:0883:[Info]->Remote plug-in API interface started on port 10400
    08:40:55:0897:[Startup]->Checking for available plug-ins
    08:40:56:3853:[Web Server]->Web Server authorized local login successful from: 192.168.0.161 User: default
    08:40:56:6743:[Plug-In]->Found plug-in: Z-Wave, version: 3.0.2.0
    08:40:56:6791:[Startup]->Initializing Plug-Ins
    Connecting to server at 127.0.0.1...
    08:40:58:2555:[Info]->Plugin Z-Wave has connected. IP:127.0.0.1:50956
    Connected, waiting to be initialized...
    08:40:58:2997:[Starting Plug-In]->Initializing plugin Z-Wave ...
    08:40:58:3321:[Z-Wave]->InitIO called, plug-in version 3.0.2.0 is being initialized...
    Z-Wave Plugin: OS Type is Linux
    08:40:58:7893:[Z-Wave]->Database: Opening (Mode=Read Only) up HomeSeer database /root/homeseer/Data/Z-Wave/Z-Wave2.db
    08:40:59:6125:[Starting Plug-In]->Plugin Z-Wave started successfully in 1312 milliseconds
    08:40:59:6413:[Z-Wave]->0 event actions were loaded from HomeSeer.
    08:40:59:6491:[Z-Wave]->0 event triggers were loaded from HomeSeer.
    08:40:59:6588:[Starting Plug-In]->Z-Wave loaded in 2921 milliseconds
    08:40:59:6603:[Plug-In]->Finished initializing plug-in Z-Wave
    08:40:59:7546:[HSTouch Server]->Server started on port 10200
    08:40:59:8286:[Z-Wave]->465 Simple AV Control Command Class Control Commands have been loaded successfully.
    08:40:59:8442:[Startup]->HStouch server started, waiting for clients to connect.
    08:40:59:8681:[Startup]->Running the startup script Startup.vb
    08:41:00:9106:[Z-Wave]->*********************************************************** ********************
    08:41:00:9162:[Z-Wave]-> STARTUP COMPLETE: All configured interfaces were successfully initialized.
    08:41:00:9284:[Z-Wave]->*********************************************************** ********************
    08:41:04:2339:[Startup]->Starting Event Scheduler...
    08:41:04:2380:[Startup]->HSSentry is disabled in Setup, sentry will not be started.
    08:41:04:2422:[Info]->Checking device parent child relationships...
    08:41:04:2461:[Info]->No device issues found
    08:41:04:2469:[Startup]->Start up complete.
    Type 'shutdown' to shutdown HomeSeer
    
    > 08:41:04:2796:[Startup]->Scripting is OK and is now running Startup.vb
    08:41:04:3909:[TTS]->Speak ():Welcome to Home-Seer
    08:41:04:4878:[Info]->System connected to MyHS Service, waiting for acknowledge...
    File upload thread started
    08:41:04:6489:[Info]->System connected to MyHS Service successfully with license ID 662375.
    08:41:06:0851:[TTS]->Speak ():Web server port number is 724

    #2


    08:31:31:5564:[Warning]->Error starting web server, port in use? Are you running a web server on the designated port? Edit settings.ini in the Config folder and change gWebSvrPort=## to a different port #. Address already in use

    Comment


      #3
      Once you shut down the service, check if it's still loaded. Do a ps aux | grep -i go .

      Also, move the install out of your /root directory. That's not a good secure practice.

      Best to place this in /opt/

      Comment


        #4
        So, out of nowhere this all just started working. Then I moved homeseer to the /opt directory as you suggested and same issue again.

        I believe as drhtmal noted the server is already running on the same port is the issue. I think this is because the process is not getting shutdown properly when I call

        Code:
        systemctl stop hs4
        How can I have the service send the "shutdown" command to the HSConsole.exe instance of the service to have HomeSeer properly shutdown? Maybe that will fix this.

        Comment


          #5
          You need to set Working directory in the unit file.

          Unit file
          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=/opt/HomeSeer
          ExecStart=/usr/bin/mono HSConsole.exe --log
          SyslogIdentifier=HomeSeer HSx
          StandardOutput=null
          Restart=on-failure
          RestartSec=30
          KillMode=none
          TimeoutStopSec=300
          ExecStop=/opt/HomeSeer/hsstop.sh
          
          [Install]
          WantedBy=multi-user.target
          Then add this script at /opt/HomeSeer/hsstop.sh to perform the shutdown
          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
              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 -af $mono.'*'\(HSConsole\|HomeSeer\) || break
              sleep $polltime
          done

          Comment


            #6
            Thanks zwolfpack!

            Those two scripts seemed to do the trick!

            The only thing I still see in the Startup.log for HomeSeer though is that it's complaining "HomeSeer was not shut down successfully the previous time it was started." in the Startup.log file.

            Everything works fine as far as I can tell, however when the system is shutdown by the service rather than the shutdown command in HomeSeer itself this message results on next startup

            Comment


              #7
              Originally posted by otttech View Post
              Everything works fine as far as I can tell, however when the system is shutdown by the service rather than the shutdown command in HomeSeer itself this message results on next startup
              The hsstop script is intended to prevent that message. It sends the shutdown command thru the web UI.

              Make sure the script is set to be executable:

              Code:
              sudo chmod +x hsstop.sh
              Do you require a password for local access to the web UI?

              Comment


                #8
                zwolfpack,

                Originally I thought my original problem was all due to permissions so I chmod 777 the entire homeseer folder, it's still like that and all files are globally executable, same issue.

                Comment


                  #9
                  Did you install Ubuntu 20.04 with a GUI or headless?

                  K

                  Comment


                    #10
                    Originally posted by k0d3g3ar View Post
                    Did you install Ubuntu 20.04 with a GUI or headless?

                    K
                    There is really no need for a GUI if you are just running it as a server.

                    Comment


                      #11
                      Ubuntu is running headless.

                      Another interesting thing is I created a virtual device. But if I delete it, it is back after restart and it also seems to not accept it's room assignments or floor assignments. I can set them ok and they are there only until I restart.

                      Comment


                        #12
                        Originally posted by otttech View Post
                        I chmod 777 the entire homeseer folder, it's still like that and all files are globally executable.
                        That wasn't really necessary nor wise ...

                        You didn't answer the other question, Do you require a password for local access to the web UI? If so, you need to add a extra config file.

                        Comment


                          #13
                          Well the 777 was basically to.determine if it was a permissions issue. I wanted to see if that resolved it. It doesn't.

                          No I do not require a local login but it still prompts me for one. I enter nothing and I'm allowed in... How do.we explain that?

                          Comment


                            #14
                            Originally posted by otttech View Post
                            How do.we explain that?
                            I don't know, but that could be what's interfering with the shutdown script. It needs to be able to login to do the shutdown.

                            You can try adding the config file. Create a file in the Config subfolder named hsstop.ini with a single line
                            Code:
                            login="username:password"
                            This username/password is one valid for web login, not the Linux login.

                            Comment


                              #15
                              Still not working. I tried both with login as you mentioned and without. Yes, I did disable local login and added subnets 127.0.0,192.168.0

                              I just started on HS4 PRO. How bad is this beta? Are we anywhere close to a release? Seems very buggy.

                              It seems like some config is retained and some is not.

                              For the life of me I cannot get basics working either. I name the device, give it a Floor and Room name then his Save. On the devices page it shows what I set those values to correctly. Then I go to edit the device again and all those fields are blank and I have to re-enter them. Is this a known issue or is there an issue with my setup in particular?

                              Seems like basics to me...

                              Comment

                              Working...
                              X