OH2 - rm -rf /cache/ on each reboot

I’m running the apt-get version of Openhab2 on Ubuntu Mate (Pi3). Currently on openHAB 2.2.0 Build #1073, but this has been occurring for a while now.

Every time I perform a reboot of the Pi, my Openhab instance sits at;

Please stand by while UIs are being installed. This can take several minutes.

It’s literally every time, so I have written a horrible script that seems to alleviate my issues. Am I alone here, or what?

#!/bin/bash
sudo service openhab2 stop
sudo rm -rf /var/lib/openhab2/cache/
#sudo reboot now
sleep 30s
sudo service openhab2 start

You are not completely alone in that this type of error has been reported. But usually deleting tmp and cache once fixes the problem for good. I’ve not seen anyone report needing to do this every single time.

If you delete both cache AND tmp do you still need the script?

Did you already do a complete cycle?

  1. stop openHAB
  2. delete ./tmp/ and ./cache/
  3. start openHAB
  4. wait until openHAB has done its boot
  5. stop openHAB
  6. Try to restart openHAB

No you’re not alone.
Actually you could add “-Dosgi.clean=true” to EXTRA_JAVA_OPTS in /etc/default/openhab2 to make cache deletion happen automatically.
Or set the appropriate options in /var/lib/openhab2/etc/system.properties.

1 Like

I’ve set karaf.clean.cache to True, lets see how that goes.

Thanks all.

So, this nuked my /var/lib/openhab2/* dir and now OH2 won’t even think about running. Fun.

Hi @mstormi,@rlkoshak this “-Dosgi.clean=true” to EXTRA_JAVA_OPTS does not work when running docker openhab container(as a env variable), after restart the container it still stuck at the beginning:

sudo docker run --name=openhab220snap --net=host --restart=always -v /opt/openhab220/conf:/openhab/conf -v /opt/openhab220/addons:/openhab/addons -v /opt/openhab220/userdata:/openhab/userdata -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -e LC_ALL=zh_CN.UTF-8 -e USER_ID=9001 -e GROUP_ID=9001 -e EXTRA_JAVA_OPTS=-Dosgi.clean=true -t -d openhab/openhab:2.2.0-snapshot-armhf-debian

result:
Please stand by while UIs are being installed. This can take several minutes.

but manually sudo rm -r /userdata/cache /userdata/tmp folder then restart the container it works.
however everytime I restart the openhab container it happens again, everytime.

I don’t know how to execute the command sudo rm -r /userdata/cache /userdata/tmp automatically everytime when the openhab container gets restart(or losing power), should I need to buld a dockerfile

also where to find the system.properties file inside a docker container?

test in openhab 2.2.0snapshot 1702, always get the same result, but never happen in 2.1.0 stable version

Ouch. Sorry to hear about that. I know it’s cold comfort to call that a bug but for sure that’s not what it should do. I hope you have a backup at least of the jsondb subdir.
A reinstallation of the Linux package should recreate those dirs (but you’ll be missing the jsondb).
But play it double safe. DON’T purge the package to avoid further unwanted deletions.

I’d actually toyed with nuking the whole instance, so backed up my /etc/openhab2/ dir, and blew it all away. I’d converted all my OH1 stuff into .things & .items, so shouldn’t be too tricky to get back to where I was.

…he says.

I applied the same change to my new fresh install, and its working as expected now! I’ve changed to Raspbian base instead of Ubuntu, but I’m not sure thats the reason its working. I have some incline I had further underlying issues!

Can you verify? Does the option not work or does the option fail to fix your problem? If the option is working you should see the cache folder emptied out when the container restarts.

Since you are mapping userdata to /opt/openhab220/userdata you can find that file in /opt/openhab220/userdata/etc/system.properties

Hi @rlkoshak sir
here is what I done from the beginning, I first run the command:

sudo docker run --name=openhab220snap --net=host --restart=always -v /opt/openhab220/conf:/openhab/conf -v /opt/openhab220/addons:/openhab/addons -v /opt/openhab220/userdata:/openhab/userdata -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -e LC_ALL=zh_CN.UTF-8 -e USER_ID=9001 -e GROUP_ID=9001 -e EXTRA_JAVA_OPTS=-Dosgi.clean=true -t -d openhab/openhab:2.2.0-snapshot-armhf-debian

everything is working so far, the page redirects and I can install binding from paperui, and then I restart the container, works very well without any stucking problem…(I’ve done many times, the problem seems gone)
I also checked the size of the /userdata/cache by running this command sudo du -sch cache/ when each restart
and I get 61M total size all the time( of cuz with -Dosgi.clean=true enabled, but the cache folder is not empty everytime I restart, it always remains the same 61M size), in this case, the stucking problem seems never happen.

but…


Here is how I can reproduce the “stucking process” at the “Please stand by while UIs are being installed. This can take several minutes.” page…(only for the 2.2 snapshot version, not the 2.1.0 stable docker version, the 2.1 always working btw…)

the different is: this time I manually upload the “openhab-addons-2.2.0-SNAPSHOT.kar” file to the /addons folder first (due to some slow internet connection, I always prepare the “offline” addon file, downloaded from HERE)

and thenl I run the docker command exactly the same as above

the docker openhab booted and redirects to the index page, I still can install binding from paperui(with offline addon files it install much more quicker), and then I restart the docker container immediately, the stucking problem happen…

in this case, no matter how many times I restart the container, the page seems always stucking at that stage unless I manually delete the /cache and /tmp folder, then it redirects to the index page correctly, and give it another restart it will stuck to that “Please stand by” page again…

I don’t know if the .kar file causing this problem, but I did exactly the same process to 2.1.0 stable version, it always working very well…


I didn’t modify the “system.properties.” files if you ask, I think the EXTRA_JAVA_OPTS=-Dosgi.clean=true tells docker to clean the cache, but I will try to modify this files and get back to you later

I hope sir you can guide me through this, thanks


edit:
I delete the “openhab-addons-2.2.0-SNAPSHOT.kar” file and restart the docker container, this time it redierects to the index page without any problem, lolz… looks like the .kar file causing this problem… sorry about that…(I have to download addons online when I install bindings…sad T_T)

I also doubt that with env variable set to -e EXTRA_JAVA_OPTS=-Dosgi.clean=true it seems not working at all, docker seems like not perform any cleaning process during restart (both /cache and /tmp folders)

I modify system.properties file, edit karaf.clean.cache=true is working, the /cache is empty when restart, no stucking page::grin:

I modify system.properties file, edit karaf.clean.cache=true but keep the .kar file in addons folder, it stucks again after restarting the container…:persevere:

Shane

I’m not sure that this would tell you is the Dosgi.clean=true is working because OH is going to delete the contents of the folder and immediately repopulate it with a fresh set of files. And without any changes to your config I would expect the cache to remain the same size. So unless you happen to time the du command just right that you catch it after it deletes the cache and before it is done recreating the cache files you wouldn’t see a difference.

Aha! There is your problem. This was announced awhile back. The offline bindings support is currently broken in the SNAPSHOT. There is an issue open and it is being worked. For now only online is supported.

@rlkoshak
edit:
I delete the “openhab-addons-2.2.0-SNAPSHOT.kar” file and restart the docker container, this time it redierects to the index page without any problem, lolz… looks like the .kar file causing this problem… sorry about that…(I have to download addons online when I install bindings…sad T_T)

I also doubt that with env variable set to -e EXTRA_JAVA_OPTS=-Dosgi.clean=true it seems not working at all, docker seems like not perform any cleaning process during restart (both /cache and /tmp folders)

I modify system.properties file, edit karaf.clean.cache=true is working, the /cache is empty when restart, no stucking page::grin:

I modify system.properties file, edit karaf.clean.cache=true but keep the .kar file in addons folder, it stucks again after restarting the container…:persevere:

You are right sir… sorry about that…:persevere: guess i have to face the slow internet problems

Yeah I run the command almost like realtime… I can see the /cache folder size growing and growing (by edit karaf.clean.cache=true)

but I don’t see any size changing(a fixed size) when restarting the docker container (using the env variable without edit the system.properties file)

anyway thank you so much sir ^.^

Shane

OK, it is probably worth filing an issue on the openhab-docker repo if you would be willing. The environment variable should work too and if it doesn’t work for this option it probably doesn’t work for others.

I have the exact same issue, doing a reboot or shutdown from Karif I have to delete Cache & Temp before things works again, I’v had this issue since Build #1073

I’m running my Openhab2 on CentOS 7.0

Are you using the offline add-ons Kar file? If so that is the problem. There is a bug and the offline Kar file is not working.

I have removed the offline add.ons Kar files, and in Paper-Ui in add on management set “Access Remote Repository” would this be the correct approach?

I believe so. I’ve never used the offline Kar so can’t say for sure but what you say sounds right.