Announcement

Collapse
No announcement yet.

[INFO] HS systemd script

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

    [INFO] HS systemd script

    hey guys - new to HomeSeer, but not HA in general. I was confused when I searched high and low for a systemd init script for HomeSeer, and couldn't find one. Anyways, here is what I'm using for my init script on ubuntu 16.04
    All that is required is to first create the following script:
    Code:
    vi /lib/systemd/system/homeseer.service
    make sure it has the following contents (note- replace your own homeseer home value in place of /root/HomeSeer)
    Code:
    [Unit]
    Description=HomeSeer
    After=network.target
    
    [Service]
    WorkingDirectory=/root/HomeSeer
    ExecStart=/usr/bin/mono /root/HomeSeer/HSConsole.exe --log
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    Then enable the service:
    Code:
    systemctl enable homeseer.service
    If this helps out just 1 person, all my struggles were worth it Let me know if you have any questions!
    Last edited by jon102034050; June 13, 2016, 09:57 PM.

    #2
    I have screen installed and use that to launch HS via script. Not sure what the path is to the screen executable. So I can include it. Here is how I launch it now. Can I still setup HS to launch via your method and use the screen option?

    screen -S homeseer -dm sudo mono HSConsole.exe --log

    Comment


      #3
      Originally posted by srodgers View Post
      I have screen installed and use that to launch HS via script. Not sure what the path is to the screen executable. So I can include it. Here is how I launch it now. Can I still setup HS to launch via your method and use the screen option?

      screen -S homeseer -dm sudo mono HSConsole.exe --log
      Why do you want to use screen? As I understand it, the only reason to use screen is to keep track of the process and easily kill it at shutdown. systemd takes care of a lot of this for you.

      Comment


        #4
        Not sure. Seen the example and like being able to connect to the HS3 session and then detach.


        Sent from my iPhone using Tapatalk

        Comment


          #5
          Did not work. Does homeseer.service have to be executable. chmod +x? I am kind of a noob but know some basics.

          Comment


            #6
            here are the permissions of my homeseer.service file:

            # ll /lib/systemd/system/homeseer.service
            -rw-r--r-- 1 root root 176 Jun 12 12:40 /lib/systemd/system/homeseer.service

            what is the error you're getting?

            Comment


              #7
              Noob mistake. I forgot the last step:

              systemctl enable homeseer.service

              Works now and I can see it listed in services on webmin. How do I attach to the session where HS is running to view its output and shut it down?

              Comment


                #8
                Code:
                Jun 13 21:05:45 raspberrypi mono[574]: 09:05:45:1262:[Error]->Compiling script /usr/local/HomeSeer/scripts/UpDateTime.vb: Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.0.1 - tarball)
                Jun 13 21:05:45 raspberrypi mono[574]: Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.
                Jun 13 21:05:45 raspberrypi mono[574]: vbnc : Command line : error VBNC2017: The library 'Scheduler.dll' could not be found.
                Jun 13 21:05:45 raspberrypi mono[574]: There were 1 errors and 0 warnings.
                Jun 13 21:05:45 raspberrypi mono[574]: Compilation took 00:00:00.6454410
                In webmin I found View Logfile module and looked at /var/log/daemon.log and see the HS output.

                When running HS this way I get the error above from vbnc not seeing Scheduler.dll. Does not have this problem when launching this the normal way via terminal and ./go script.

                Comment


                  #9
                  Originally posted by srodgers View Post
                  Code:
                  Jun 13 21:05:45 raspberrypi mono[574]: 09:05:45:1262:[Error]->Compiling script /usr/local/HomeSeer/scripts/UpDateTime.vb: Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.0.1 - tarball)
                  Jun 13 21:05:45 raspberrypi mono[574]: Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.
                  Jun 13 21:05:45 raspberrypi mono[574]: vbnc : Command line : error VBNC2017: The library 'Scheduler.dll' could not be found.
                  Jun 13 21:05:45 raspberrypi mono[574]: There were 1 errors and 0 warnings.
                  Jun 13 21:05:45 raspberrypi mono[574]: Compilation took 00:00:00.6454410
                  In webmin I found View Logfile module and looked at /var/log/daemon.log and see the HS output.

                  When running HS this way I get the error above from vbnc not seeing Scheduler.dll. Does not have this problem when launching this the normal way via terminal and ./go script.

                  Not sure about the scheduler.dll error, I do see that in my /var/log/syslog on startup, but I'm not sure if there are any repercussions or not... I haven't seen any yet, but I'm not using HS to it's fullest potential yet as I havent brought over all my HA devices from ISY yet.

                  Comment


                    #10
                    This is not just startup. It happens every time a script is called.


                    Sent from my iPhone using Tapatalk

                    Comment


                      #11
                      Originally posted by srodgers View Post
                      This is not just startup. It happens every time a script is called.


                      Sent from my iPhone using Tapatalk
                      just from googling (http://board.homeseer.com/showthread.php?t=165092) it looks like it's because HS is looking for the working directory to be the HomeSeer dir... try this out, I believe this resolved it for me:

                      Code:
                      [Unit]
                      Description=HomeSeer
                      After=network.target
                      
                      [Service]
                      [B]WorkingDirectory=/root/HomeSeer[/B]
                      ExecStart=/usr/bin/mono /root/HomeSeer/HSConsole.exe --log
                      Restart=on-failure
                      
                      [Install]
                      WantedBy=multi-user.target
                      then reload your script:

                      Code:
                      systemctl disable homeseer.service
                      systemctl enable homeseer.service

                      Comment


                        #12
                        Just changed it to that but how do it get to the Homeseer process that is running and shut it down. Before I just type shutdown in the Homeseer terminal it was launched from. That is what was neat about the screen command.

                        Comment


                          #13
                          Code:
                          systemctl stop homeseer
                          systemctl status homeseer
                          systemctl start homeseer

                          Comment


                            #14
                            Does that do a clean shutdown of HS when you give it the systemctl stop homeseer command? It seems to work ok and I have started and stopped HS this way.

                            Wish I could see and monitor the output of the session.

                            Comment


                              #15
                              Originally posted by srodgers View Post
                              Does that do a clean shutdown of HS when you give it the systemctl stop homeseer command? It seems to work ok and I have started and stopped HS this way.

                              Wish I could see and monitor the output of the session.
                              I have to do more research on systemd to understand how it's stopping the processes, but I imagine it's just doing a kill on them.

                              In terms of the stdout, are you not finding what you want in /var/log/syslog? That's where my output is.

                              Comment

                              Working...
                              X