-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Systemd service should use /bin/karaf instead of start.sh #72
Conversation
@ThomDietrich if it helps for testing, the above changes are available as a full pacakge in the linuxpkg-testing repo:
|
Excellent! I'm sadly not able to do any tests today. I'm curious how the error would look like if there is no java runtime available |
There's a weird issue with this: When a program managed by systemd sources a script, the stout buffer from that script seems delayed. In this case, when karaf calls our To see this error message in systemd, we would have to edit 'setenv' to output with:
Which is otherwise completely redundant. |
@BClark09 If it is like you suggested and the buffered stdout is cut off too early at the exit, did you find a discussion on the issue? This one looks alright: http://systemd-devel.freedesktop.narkive.com/suwZf7s7/unbuffered-stderr-for-my-systemd-service Your proposed solution does work because the otherwise useless |
There are a few scattered around (this for example), I think this is the systemd bug to watch for this issue though. |
3cd8f43
to
3772481
Compare
I think this is okay to merge now. I'll wait a bit for feedback in the above thread to see if the ulimit restriction has been adjusted. |
resources/systemd/openhab2.service
Outdated
@@ -1,5 +1,5 @@ | |||
[Unit] | |||
Description=openHAB 2 - empowering the smart home | |||
Description=openHAB 2 - Empowering the smart home |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed un-natural at it was. My intention was to capitalise the S and H in Smart Home (as it is in the docs), but I must have misplaced that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wanted to do that a few months ago but got scolded by Kai for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... I'll change it back then.
resources/etc/default/openhab2
Outdated
@@ -29,3 +29,8 @@ EXTRA_JAVA_OPTS="" | |||
# | |||
#OPENHAB_USER=openhab | |||
#OPENHAB_GROUP=openhab | |||
# | |||
# The startmode for the openHAB runtime. Only available for systemctl/systemd systems. | |||
# Defaults to daemon when unset here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we list the options here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't so sure, options for karaf are:
clean - Deletes $KARAF_DATA contents (/var/lib/openhab2)
debug - Turns on java debugging options
status - Checks if running
stop - Stops instance
console - ???
server - Starts remote shell and runs the karaf server
daemon - Same as server, extra exec and return details.
client - Starts the client to an existing instance
Out of them, we could really only recommend using daemon
, debug
or debug daemon
with systemd. Definitely don't want to mention clean
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
Signed-off-by: Ben Clark <ben@benjyc.uk>
@kaikreuzer, @theoweiss, just an FYI: I noticed there was some discussion at openhab/openhab-distro#138 about how to start using systemd. I have changed this to use Is there any reason, or can you remember any reason for this being a bad idea? Tests on Debian and Fedora have worked well, so will merge this PR soon. |
I am not aware of reason against it, but @theoweiss is indeed probably the much better person to ask about it :-) |
@BClark09 Instead of the |
I couldn't find a way of incorporating it reliably, it seems to suffer from the same race condition. Also, should we really add platform specific Linux commands to openHAB's start scripts? |
I thought about it and couldn't see a reason why not. Of course one would need to properly check for systemd beforehand.
Well nice... |
Actually, I may have been wrong in that, was looking in the wrong place. The systemd service needed a bit of tweaking to be of "notify" type. Unfortunately, this still isn't a solution, openHAB would need an implementation of sd_notify to pass down that the service has started successfully. Otherwise, the service start command would keep waiting for one and timeout. |
You mean this would need to happen inside openHAB or Karaf, not inside the bash script!? |
If you're using sd_notify, then you'll need to pass down a message that the service has started successfully, which should only happen inside the java process started by Karaf if you want to certain that everything is working correctly. |
To summarise:
I'd suggest we merge now and I can make a PR in the distro if using |
Sorry guys for not participating in this discussion but remodelling our new house and working for my paid job is still eating my whole time. May be I'm back in late autumn. @BClark09 is doing a great job here!! |
No problem @theoweiss! Hope it's all going well! |
Closes #70
Signed-off-by: Ben Clark ben@benjyc.uk