B4J Question Remote RPi Survive Power Outage Reboot

Noble

Member
Licensed User
Longtime User
I have a couple RPi's running remotely. Seldom is there a reboot. When there is I have to reload the program using B4J.
My question is How can I have the Raspberry Pi start with the bridge running and Load the last program that I loaded to it when it reboots.

I have been using /etc/rc.local to start the bridge, that always works fine.
I have tried several options to load the AsyncInput2 (jar) file and I can get it to run parts of the program, however I can not load a new program using the B4j it says there is addresses in use.

There must be a easy way to do this ... can someone point me in the correct direction?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Why do you need a B4j bridge to load an app? If you compile as release the resulting jar will be transfered to the pi there you can initialize it with a simple command:

Java -jar your.jar and it will work, yo don't need the B4j bridge at all
 
Upvote 0

Noble

Member
Licensed User
Longtime User
I would like to have the Bridge running in the background so I can easily log in change something and if there is a power reset, it will load the last program changes, initialize and run. None of my systems require preserving current variables.

If I used your simple command, where would you suggest I have that run from. (I have tried from rc.local, I2C and Webserver do not start ?)
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Bridge running in the background so I can easily log in change something and if there is a power reset,
I understand the concept but i dont think that the b4j bridge was designed to run an app outside of the IDE (or to attach itself to a running app)

that said, we actually have access to the b4j bridge source code, so you could modify it to accomplish your objectives.

this one should be fine but wrap the java -jar command with an .sh file
 
Upvote 0

Noble

Member
Licensed User
Longtime User
I guess I need a better understanding.
Upon Pi boot up, I have the B4j-Bridge start and run as a service.
When I connect to the Pi with B4J Anywhere Software compile with release program runs perfectly (actually has for years)
Once log looks good I exit the Anywhere Software, Take down the remote VPN and the software runs perfectly.
These remote systems use there own WebSocket, PiFace, OneWire and I2C .. that works well.

What I would like to solve is the problem of if the power goes off, the Pi will reboot and yes the bridge does restart, however, the last compiled program that was downloaded via the bridge does not restart.
I would like to know it there is a way to have the compiled program restart on reboot. Still leaving me the option to reconnect to the pi remotely with the bridge to look at the logging, or load a program change.

I have noticed this afternoon testing the idea of starting the program outside the bridge ( I have tried under rc.local )
the program starts and runs, however, the websocket does not work, I2C does not work, basic timers and counters do work. So I think that may have to do with how I'm starting the Job? I tried wrapping it and I get the same results.

Any thoughts would be helpful.
Kris
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
i still believe that you dont need b4j to start an application, but i guess that in your scenario is important because it allows the application to be kept alive after the rol of the b4j bridge is no longer needed.

If what you need is the app to start and be ran as a service (that means on the background) then this may be for you:

of course you can .sh this command and run it in rc.local
 
Upvote 0
Top