Running OH3 as service on server

  • Platform information:
    • Hardware: R610 Dell Server/ dual Intel Xeon/32GB/256GB SSD Boot Drive
    • OS: Windows 10 Pro
    • Java Runtime Environment:

openjdk version “18.0.1” 2022-04-19
OpenJDK Runtime Environment Zulu18.30+11-CA (build 18.0.1+10)
OpenJDK 64-Bit Server VM Zulu18.30+11-CA (build 18.0.1+10, mixed mode, sharing)

My long term plan is to place OH3 inside dockers, probably on a rpi, but to make it easier to debug and write the rules (doing everything in vscode) I am using windows 10 with RDP. The server, a dell r610 has a single boot drive, with windows 10 installed directly on it. The bays, are used for RAID storage of video recording (blueiris) and unrelated to OH3 config.

I had came across a post in the past, and I can not find it, that said something about OH3/Java having an issue detecting the correct CPUs/threads when installed on a server.

I can run OH3 from start.bat and it is stable. If I run from a service, it works for a certain amount of time and then a memory leak seams to kill it (hangs).

See the image for the wrapper.log.

I guess in the meantime I will try to get docker working, but trying to get one things working at a time without layers of complexity.

I’m pretty sure openHAB3 is not (yet) compatible with Java 18.

Oh dear. I just realised this after blinding copying, I did think I have Java 11 installed. I will try that and see what happens.

openjdk version “11.0.16” 2022-07-19 LTS
OpenJDK Runtime Environment Zulu11.58+15-CA (build 11.0.16+8-LTS)
OpenJDK 64-Bit Server VM Zulu11.58+15-CA (build 11.0.16+8-LTS, mixed mode)

It at least connects to myopenhab cloud. When started as start.bat it seems to work okay, but as a service is still causing hangs in the logs.

Hi,
Can you explain a bit more on what you mean run as a service? Are you actually trying to start it up using a system managed custom user service and running using the network service or system account?
or are you
running it as a one-time scheduled task (run as administrator) using the same credentials and run regardless of is user is logged on or not?
You may be having an issue where the java environment is not being correctly setup due to user environment and memory space not being correctly established when a user is not logged on.
There are some specific extra settings (best practices) you may want to explore when running java-based apps as a service on windows.

Did you set your java environment variables under the system variables or under user variable environment settings?
also, when you run it from start.bat on the desktop does it also have any issues at all after extended runtimes?
Also, just because you’re running on a dell hardware product that is called “server” does not mean you are running on server OS. windows 10 is not a server OS it is a workstation OS although it is the same base core some features for workstation does not behave the same as on server OS specifically around the user memory space management.
I have run an openhab 3.2 instance on a server 2019 and also 2016 OS as a scheduled task set to start regardless of if user is logged on or not for months at a at time and not run into any memory heap issues like you are seeing. I have also run openhab 3.2 on a Hyper-V instance of windows and Linux and as a docker image inside a Hyper-V instance of windows and on a Linux Hyper-V vm and an install of OpenShift (Kubernetes) pod none have had the kind of memory leak issues you mention for what it’s worth.
oh, and mine is a 3-node dell r710 Hyper-V cluster with 288 GB of ram dual hex core Xeon X5660 per node and sas ssd’s and running the Hyper-V vm’s off the CFS share on a dell MD 3600 series disk array with dual 8 gb MPIO fiber links
so really doubt your problem is a server hardware related issue.

Hi Justan,

Thanks for the detailed reply. I am using a R610 and have windows 10 pro (desktop, not server edition) running from a SSD drive connected to the PCIe slot with an adapter. This is just a temporary solution as I develop the code/rules etc. I got the server second hand and didnt realise the raid card could not be used in IT mode, so unlike my previous OH3 install that was running on the R720 I have on a windows VM inside proxmox (on SSDs in the drive bay with IT mode raid card), I can’t seem to get it working as a service.

By service, I followed the steps on OH install guide and am running it automatically on start up. In the past on OH2.5 I had manually added the service with nssm with the config passed as an argument, but for OH3 I was following the guide from the docs. [ Windows | openHAB]

I mentioned a hardware issue, because I remember seeing a post about OH/Java detecting the CPU threads incorrectly, and since I am not using a VM I can’t configure the environment like that, but I may be mistaken (I cant find that post now).

Yes, the JAVA_HOME variable has been set correctly I believe.
image
Should it be JRE or JDK? I have used both in the past, and just want to confirm I am not using the wrong one.

As far as I can tell, starting OH3 in a terminal with start.bat is working as expected. I have local/remote control via myopenhab cloud.

Hi,
look carefully at the prerequires link and notice it shows adding java_home as a system variable not user variable as you screen shot is showing.
" Set the JAVA_HOME System Environment Variable in Windows

  • Navigate to: Control Panel :arrow_right: System and Security :arrow_right: System :arrow_right: Advanced System Settings :arrow_right: Environment Variables :arrow_right: System Variables
  • Create a New System Variable named JAVA_HOME (or update the existing one) to match the installation directory of the Java Platform chosen and installed in the step Prerequisites."

If I may

Can I suggest that if you intend to move all this to a SBC device with a headless Linux setup, that you do this first?

It would seem to me that you’ll cut out a lot of effort that is needed for the short term experiment.

As for which SBC to go for, you’ll find endless opinions on this forum.

My personal go to SBC is the Odroid range, specifically the Quad core C4

I’m not going to go into why, yet again, other to say that I prefer an eMMC based system over an SD card.

1 Like

You can probably use vscode over Ssh on your SBC (rpi or odroid). I do this with Linux (Ubuntu) server from a Mac laptop.

Alternatively you could share your conf folder with samba and edit via the share on vscode

1 Like

Please read the prerequisites. openHAB 3 requires Java 11. You are running an unsupported Java version.

OP is not anymore - see posts 3 & 4.

Sorry, overseen that.

I second this. If you already have the RPi, get it going with openHABian and don’t concern yourself with the Windows stuff. You’re forcing yourself to figure out things that won’t matter in the long run.

I don’t personally see a reason to run Docker if you aren’t running anything else on the SBC. It’s not bad, but it complicates things without adding a ton of benefit. That’s just my opinion though, and others disagree.

1 Like

I also agree with everything that has been added since I replied to the OP earlier but if he wants to play with it on windows first, I was not going to distract him from that approach. I just tried to guide him on what is required to make it run as he was attempting to do, I mentioned earlier that I have tried OpenHab in every conceivable manner in the past mainly just to see if it really made any difference which way it was used and or restored after screwing up something via a fat finger typo… :stuck_out_tongue:. The RPi is the most energy friendly approach for sure other methods may be less daunting depending on what the OP’s comfort level is with RPi and docker or any ssh configuration approach but mainly I wanted to reassure him it was not a server hardware related issue as he mentioned…

2 Likes

Thanks everyone. I wont have time for a few days to work on this but I have read the replies and will try fixing the java_home as suggested. I will post another reply with my progress when I do.

The main reason I am using windows is that I need to run blueiris for security cameras, so it is running anyway. It also has grafana/influx/mqtt etc on it. I did have openhab 2 running on a rpi years ago, and while its certainly possible to ssh etc with it, having it on windows now is just easier since I can both RDP into it but also since it is a server I can remotely manage it etc (using iDrac from Dell).

I am just starting my career in electrical engineering and embedded level programming, but don’t have much experience until recently with servers/linux, so this is also a learning opportunity for me. I am doing my own code for the ESP devices, so I have been focused on that and haven’t yet spent the time to get OpenHab running the most efficient way, its on the end of a long list :slight_smile:

1 Like