Server on Raspberry pi 4

Hi, I’m running the Blynk server on a “headless” raspberry Pi 4, works like a dream and I have cloned my apps across, but I have the old problem that when I close the ssh terminal on my Mac the server also stops working. I can see old threads of adding “ &’ into a file somewhere and using crontab but this isn’t supported on the Pi 4. It comes with the “nano” editor.
I have no clue how to find the file and edit it. (I’ve tried find but it finds nothing!)

Also do I need “Docker” the RaspPi server set up instructions are not very clear on what is needed.

Thanks for any help

Please have a look at (nano is default editor of RPI)

and

Hi Khoih,
Thanks for rapid reply, I am very new to RPi and local servers as you can gather. I followed the instructions in the Blynk doc.
On my Pi If I do “ls” I can see :- Blynk logs server-0.41.12-java8.jar static
If I start the server with the ampersand & and then close my terminal the server stops immediately.

im now on the mac so I can copy things directly:-
this is what I get when I log on …
pi@raspberrypi : ~ $ ls

Blynk logs server-0.41.12-java8.jar static

pi@raspberrypi : ~ $

and then when I start the server …
pi@raspberrypi : ~ $ java -jar server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &

[1] 661

pi@raspberrypi : ~ $

Blynk Server successfully started.

All server output is stored in folder ‘/home/pi/logs’ file.

I tried your “nano” edit file, and could edit and save as you directed but the server did not start once I started the RPi again.

Can you post the output of these commands

pi@raspberrypi  :  ~ $  pwd
pi@raspberrypi  :  ~ $  ls -la
pi@raspberrypi  :  ~ $  uname -a
pi@raspberrypi  :  ~ $  find . -name server-0.41.12-java8.jar -print
pi@raspberrypi  :  ~ $ java -jar server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &
pi@raspberrypi  :  ~ $  cat /etc/rc.local

Another question is why you don’t update to Java11 and Raspbian Buster?

Hi, Answers below:-
pwd

/home/pi

ls -la
total 18556
drwxr-xr-x 7 pi   pi       4096 Jan 15 12:50 .
drwxr-xr-x 3 root root     4096 Sep 26 01:09 ..
-rw------- 1 pi   pi        821 Jan 15 14:17 .bash_history
-rw-r--r-- 1 pi   pi        220 Sep 26 01:09 .bash_logout
-rw-r--r-- 1 pi   pi       3523 Sep 26 01:09 .bashrc
drwxr-xr-x 6 pi   pi       4096 Jan 13 14:02 Blynk
drwx------ 3 pi   pi       4096 Jan 12 07:01 .gnupg
drwxr-xr-x 3 pi   pi       4096 Jan 15 12:50 .local
drwxr-xr-x 3 pi   pi       4096 Jan 15 09:27 logs
-rw-r--r-- 1 pi   pi        807 Sep 26 01:09 .profile
-rw-r--r-- 1 pi   pi         66 Jan 15 12:50 .selected_editor
-rw-r--r-- 1 pi   pi   18944356 Dec  6 08:27 server-0.41.12-java8.jar
drwxr-xr-x 6 pi   pi       4096 Jan 15 14:40 static
-rw-r--r-- 1 pi   pi        165 Jan 12 07:55 .wget-hsts

uname -a
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux

find . -name server-0.41.12-java8.jar -print

./server-0.41.12-java8.jar

java -jar server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &

[2] 932

**pi@raspberrypi** : **~ $** Server ports are busy. Most probably server already launched. See /home/pi/./logs for more info.

cat /etc/rc.local

#!/bin/sh -e

#

# rc.local

#

# This script is executed at the end of each multiuser runlevel.

# Make sure that the script will "exit 0" on success or any other

# value on error.

#

# In order to enable or disable this script just change the execution

# bits.

#

# By default this script does nothing.

# Print the IP address

_IP=$(hostname -I) || true

if [ "$_IP" ]; then

printf "My IP address is %s\n" "$_IP"

fi

java -jar /home/pi/Blynk/server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &

exit 0

I didn’t update to java 11 because all the docs say use java 8

I downloaded the raspberry pi system that was recommended on the RPi site.

Thanks again for your help!

In your rc.local, you’re expecting server-0.41.12-java8.jar is in /home/pi/Blynk/ folder

java -jar /home/pi/Blynk/server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &

But it actually placed in /home/pi/ folder

./server-0.41.12-java8.jar

You can either

  1. Move the server-0.41.12-java8.jar file to /home/pi/Blynk

pi@raspberrypi : ~ $ cd ~
pi@raspberrypi : ~ $ mv server-0.41.12-java8.jar Blynk
pi@raspberrypi : ~ $ ls -la Blynk

or

  1. Change /etc/rc.local (not advisable) from

java -jar /home/pi/Blynk/server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &

to

java -jar /home/pi/server-0.41.12-java8.jar -dataFolder /home/pi/Blynk &

Good luck

Hi Khoih,
again thanks for your reply, I guessed there was a mismatch from the “find . -name server-0.41.12-java8.jar -print” answer, but had no clue doing the move, RPi is like going back to pre dos days! (yes I can remember those days!)
OK so I did the move as you suggest and now the system starts and I don’t need to invoke ssh to get the server running!
Thank you so much!
My last issue is getting the Blynk apps to work when I’m outside of network. Ive done port forwarding on my network router, but this sits behind another router which connects to my ASDL internet connection. I guess I need to look at that too.

anyhow a big thank you!

1 Like

You’re very welcome and can start research from these links

and

Hi Again,
and again many thanks, it looks like I am double NAT so more research needed!

Cheers!

Check out IOTstack, it’s a Docker stack and now supports Blynk server.

I’ve been using it for a while now and made a small code contribution.

Oh my! There’s a lot to take in there GCG. I’ve just got my local server running ok, thanks to Khoih there are just a few minor things to fix like getting webhooks and external access to work and then I’m happy, but thanks for the info.

1 Like

Hi all,
Just in case it’s of use to others, I adopted a hardware solution. I now have two NodeMCU minis running back to back. One is connected to the blynk server and can accept webhooks etc and one is connected to my local server. I use the RX Tx lines of the two minis (rx to tx and tx to rx) so they can communicate and on the local server side I use the bridge widget to send / receive data. As I use the virtual ports the data that can be sent is virtually limit less and of course I preserve data security as there is still no direct link between my local server and the outside world. After an afternoon of build hardware and software it works a dream!
Again thank you all for your help.

1 Like

Crontab and ampersands are so 2010s :wink: systemd is the future :stuck_out_tongue:

1 Like

Many thanks for this, my system is still in build phase, when stable I will check this out!
Should make a good general article