openhab / openhabian

openHABian - empowering the smart home, for Raspberry Pi and Debian systems
https://community.openhab.org/t/13379
ISC License
818 stars 251 forks source link

Create specific "openhabian" line in configuration file: /etc/defaults/openhab2 #522

Closed johanneskropf closed 4 years ago

johanneskropf commented 5 years ago

Hello, on a Raspberry 3B+ running openhabian and Openhab 2.4 I encounter an issue where if I check the three prepare serial port options in preparation of a razberry and than reboot I can't reach the openhab2 service anymore. I can connect to the Pi over SSH without an issue. But can't reach anything openhab related. This perceists if I reboot. Once I uncheck the options again and I reboot everything is back to working normally.

ThomDietrich commented 5 years ago

Hey Johannes, could you please switch on the third option, then post the content of your /etc/defaults/openhab2 file? Thank you

My assumption: Parameters added to EXTRA_JAVA_OPTS are conflicting with the 3B+. If you want to help it would be interesting to know which setting causes the problem.

johanneskropf commented 5 years ago

I will switch on only the the third option and than send a copy of the EXTRA_JAVA_OPTS. The only thing that is in there now that I added is Symlink stuff.

johanneskropf commented 5 years ago

Openhabian adds this:

EXTRA_JAVA_OPTS="-Xms250m -Xmx350m -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0" # serial ports added by openHABian EXTRA_JAVA_OPTS="-Xms250m -Xmx350m -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0" # serial ports added by openHABian

It over wrote my Symlinks 🀨 When I un check the option in the Openhabian configs it leaves the /default/ooenhab2 like this

EXTRA_JAVA_OPTS="-Xms250m -Xmx350m" EXTRA_JAVA_OPTS="-Xms250m -Xmx350m"

I think it added two lines because I put my Symlinks in a second line of extra Java opts in addition to the line EXTRA_JAVA_OPTS="-Xms250m -Xmx350m" but that line with the Symlinks wasn't there when I had the Problem.

ThomDietrich commented 5 years ago

First thing to note: We shouldn't blindly overwrite user-provided options like your Symlinks addition.

Secondly: The name EXTRA_JAVA_OPTS is just a variable and is such will be overwritten by a second line. The first one in your case does hence not matter to the system. You'd need to do something like this (not tested):

EXTRA_JAVA_OPTS="my specific symlinks stuff" # user defined
EXTRA_JAVA_OPTS="-Xms250m -Xmx350m $EXTRA_JAVA_OPTS" # openHABian, do not edit

@EliasGabrielsson @mstormi wdyt? Something worth implementing?

johanneskropf commented 5 years ago

My Symlinks were never working right, now that I put it in one line like this:

EXTRA_JAVA_OPTS="-Xms250m -Xmx350m -Dgnu.io.rxtx.SerialPorts=/dev/ttyEnocean:/dev/ttyZwave:/dev/ttyZigbee"

They are working just fine. So it doesn't seem to work to have two lines of EXTRA_JAVA_OPTS in the openhab2 file.

paulipaul commented 5 years ago

Hello, I have a similar problem but I don't use Symlinks. I have a fresh installed Openhabian with OpenHab. I did not configure OpenHab 2 yet. When I check the three serial Ports setting (especially the third one) OpenHab won't start.

When I type in

sudo systemctl status openhab2 <

I get following error message:

openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
   Active: deactivating (stop) (Result: exit-code) since Sat 2019-01-19 19:16:44 CET; 643ms ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
  Process: 3730 ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE (code=exited, status=1/FAILURE)
 Main PID: 3730 (code=exited, status=1/FAILURE);         : 3842 (karaf)
   CGroup: /system.slice/openhab2.service
           └─control
             β”œβ”€3842 /bin/sh /usr/share/openhab2/runtime/bin/karaf stop
             β”œβ”€3918 /usr/bin/java -version
             └─3919 grep ^IBM

Jan 19 19:16:42 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.
Jan 19 19:16:43 openHABianPi karaf[3730]: Error: Could not find or load main class serial
Jan 19 19:16:43 openHABianPi systemd[1]: openhab2.service: main process exited, code=exited, status=1/FAILURE
EliasGabrielsson commented 5 years ago
EXTRA_JAVA_OPTS="my specific symlinks stuff" # user defined
EXTRA_JAVA_OPTS="-Xms250m -Xmx350m $EXTRA_JAVA_OPTS" # openHABian, do not edit will be automatic overwritten.

@ThomDietrich Having one "line" for openhabian like your idea above is great. I think we should create a helper function handling this, eg.

## Add Java option to openhab used while starting the service
## 
##      addOpenhabOption(String option) { 
## 

addOpenhabOption() {
 - Adds new option to openhab config file.
 -  Create specific openhabian line if not exist
}

This also ensures that we can write tests for it ;-)

ThomDietrich commented 5 years ago

@EliasGabrielsson πŸŽ– for thinking generalized AND test driven 😊

There are 2-3 spots that need to be replaced. The default option introduced by @mstormi would need to be part of the function?

mstormi commented 4 years ago

I'd think there is no longer a need for this.