OH2.2.0 unable to start via LaunchDaemon on macOS

startup
osx
macos
Tags: #<Tag:0x00007fd3105326f0> #<Tag:0x00007fd3105325b0> #<Tag:0x00007fd310532470>

(Bryan Coles) #21

Anyone find a solution to this basic problem?


(Jonas) #22

i made the start.sh executable and added it to the start items for my account.
it’s not beautiful because a terminal window is shown but it works.

i have the problem that oh constantly restarts when i configure the daemon.
maybe a launch agent is the way to go? i am not a developer so i don’t know exactly.

regards

jonas


(Holger Hees) #23

maybe this helps

for me the problem was the karaf console. You can see it on this line

Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)

so I don’t use the start.sh script if I run it as a daemon

using the start.sh script works for me until version 2.1.0 but not after.


(Berthold Alfes) #24

Hi Holger, you mention that you don’t use start.sh when starting openHAB as a daemon. How do you start it then? Can you share your plist file? I tried to start karaf directly but still get the same error with the dumb terminal and eventual shutdown.

Thanks!


(Berthold Alfes) #25

Hi everyone, I think I found a solution to this problem by adding the parameter ‘server’ to the launchscript for karaf. I think this make sure karaf doesn’t try to launch a terminal:

#!/bin/sh

echo Launching the openHAB runtime…

DIRNAME=dirname "$0"
exec “${DIRNAME}/runtime/bin/karaf” server “${@}”


(Holger Hees) #26

Hi @Berthold. My startscript works similar. The main problem was that the start.sh script is starting karaf with parameter “start”. (internally the start.sh script calls “…/karaf start”) This includes the startup of the karaf console which is the reason why the rest does not work.

I’m just surprised that there is a parameter “server”. I use the parameter “daemon”.

So what I call from my daemon script is “…/karaf daemon”. This disables the karaf console and everything works fine.

Now you have to options. Either modify start.sh to use the

I changed it to


(Jonas) #27

can you please post your daemon here?
i am still stuck at this …
I managed to make an executable start.command that starts the karat like the start.sh does.
but this opens a terminal window.


(Holger Hees) #28

I’m not sure if this helps you, because I’m using systemd

at the end you can use the start.sh script too. Just be sure that you call it with the parameter “daemon”

means something like “start.sh daemon” should work. If this is not enough you can also export the environment variable OPENHAB_STARTMODE=daemon. But I guess this variable was just a helper and is not really needed.


(Manolo) #29

I found the solution at apache.org.
See this link: Karaf Wrapper

You simply login to the Karaf console and enter:

openhab> feature:install service-wrapper
openhab> wrapper:install

A *.plist file will be generated and you get instructions how to install and start as a LaunchDaemon.
Hth,
Manolo


(Jonas) #30

hmmm did not work for me. I copied the plist (per drag and drop but that should not matter) into launch deamons and set the rights as described but OH does not start :frowning:


(Manolo) #31

Sorry Jonas88

I had a check again and it seems that the karaf wrapper doesn’t work out of the box with openhab2.
There are some issues with the karaf config.

Nonetheless using the start.sh adding the server parameter should work. Did you test it?


(Jonas) #32

i had to rename start.sh into start.command to be able to execute it at startup.
do you mean I just have to add the server parameter there or how did you execute the start.sh at launch? did you create the .plist linked In the article for OH1?


(Manolo) #33

On which operating system are you using openhab? macOS?


(Jonas) #34

jup mac os 10.13.5
edit: I’ll give it a try with the server parameter in the .command file. reporting back in a minute


(Jonas) #35

ok further progress using the parameters.
server: the terminal window has to stay open or it will quit the server (makes sense).
daemon: I can quit the terminal window and openhab is still running. :slight_smile:
now I just need to quit the window after execution. :slight_smile: any advice?


(Manolo) #36

Well it is suffice to create a start.sh file or use the existing one. It needs to be made executable

chmod 755 start.sh

my start.sh:

#!/bin/sh

echo Launching the openHAB runtime...

DIRNAME=`dirname "$0"`
exec "${DIRNAME}/runtime/bin/karaf" server "${@}"

My plist in LaunchDaemons looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
	    <key>StandardOutPath</key>
	    <string>/Users/macadmin/Desktop/openhab2/daemon.log</string>
	    <key>StandardErrorPath</key>
	    <string>/Users/macadmin/Desktop/openhab2/daemon.log</string>  
	    <key>KeepAlive</key>
	    <false/>
	    <key>Label</key>
	    <string>org.openhab.server</string>
	    <key>EnvironmentVariables</key>
	    <dict>
	      <key>OPENHAB_HTTP_PORT</key>
	      <string>9080</string>
	      <key>OPENHAB_HTTPS_PORT</key>
	      <string>9443</string>
	    </dict>
	    <key>ProgramArguments</key>
        <array>
                <string>/Users/macadmin/Desktop/openhab2/start.sh</string>
        </array>
	    <key>RunAtLoad</key>
	    <true/>    
	    <key>UserName</key>
		<string>macadmin</string>
	</dict>
</plist>


(Rtaxerxes) #37

Thank you so much, this has sorted it for me. I’m using the same LaunchDaemon, and just added the server to the start.sh and it works. Now running 2.3 on MacOS.


(Jonas) #38

You sir are a hero :slight_smile:
Thanks a lot!

Can someone include this daemon, start.sh-modification and an instruction on how to create a plist and own it to root on Mac OS to the openHAB Logs?


(John) #39

Just wanted to say thanks for all the folks in this thread, I ran across the issue and updating start.sh solved it for me.