Blynk Server version v0.17.2 released

What is the easiest way to update this on raspberry Pi?

Do I lose everything by updating?
Or do I need to back things up?

No. All your data is stored in dataFolder that you should specify during start.

I made a startup script for this situation, I always make a symbolic link to the server-xx.x.jar file called server.jar so I don’t have to adjust the script file. Here’s the snippet, I believe it has been posted before, but hey, the Internet is a big place :wink:

#!/bin/sh
#

BASE=/tmp
PID=$BASE/blynk.pid
LOG=$BASE/blynk.log
ERROR=$BASE/blynk-error.log

COMMAND="/storage/java/jre/bin/java -jar /storage/blynk/server.jar -dataFolder
/media/Data2/blynk-files"

status() {
       	echo
       	echo "==== Status"

       	if [ -f $PID ]
       	then
       		echo
       		echo "Pid file: $( cat $PID ) [$PID]"
       		echo
       		ps -ef | grep -v grep | grep $( cat $PID )
       	else
       		echo
       		echo "No Pid file"
       	fi
}

start() {
       	if [ -f $PID ]
       	then
       		echo
       		echo "Already started. PID: [$( cat $PID )]"
       	else
       		echo "==== Starting"
       		touch $PID
       		if nohup $COMMAND >>$LOG 2>&1 &
       		then
       			echo $! >$PID
       			echo "Done"
       			echo "$(date '+%Y-%m-%d %X'): START" >>$LOG
       		else
       			echo "Error"
       			/bin/rm $PID
       		fi
       	fi
}

kill_cmd() {
       	SIGNAL=""; MSG="Killing "
       	while true
       	do
       		LIST=`ps -ef | grep -v grep | grep server.jar | awk '{print$1}'`
       		if [ "$LIST" ]
       		then
       			echo; echo " $MSG $LIST" ; echo
       			echo $LIST | xargs kill $SIGNAL
       			sleep 2
       			SIGNAL="-9" ; MSG="Killing $SIGNAL"
       			if [ -f $PID ]
       			then
       				/bin/rm $PID
       			fi
       		else
       			echo; echo "All killed" ; echo
       			break
       		fi
       	done
}

stop() {
    echo "==== Stop"

    if [ -f $PID ]
    then
        if kill $( cat $PID )
        then echo "Done."
             echo "$(date '+%Y-%m-%d %X'): STOP" >>$LOG
        fi
        /bin/rm $PID
        kill_cmd
    else
        echo "No pid file. Already stopped?"
    fi
}

case "$1" in
    'start')
            start
            ;;
    'stop')
            stop
            ;;
    'restart')
            stop ; echo "Sleeping..."; sleep 1 ;
            start
            ;;
    'status')
            status
            ;;
    *)
            echo
            echo "Usage: $0 { start | stop | restart | status }"
            echo
            exit 1
            ;;
esac

exit 0

Make sure to change the COMMAND parameter to your liking and system :slight_smile:

3 Likes

so, i have 0.00001 XP points with Linux, do i just:

  1. remote to my Raspberry Pi via VNC Viewer
  2. open terminal
  3. right click, paste your script
  4. change COMMAND to my system
  5. watch it do stuff
  6. reboot Raspberry Pi

if my server .jar is stored in /home/pi/ would you know what my COMMAND line should be?

@Dave1829 that is almost right.

1b Copy the new server jar file to the Pi and if you don’t create symbolic links then save it as server-0.17.2.jar. If you use symbolic links then save it as server.jar. Remembering to save your old jar file to something like server.001 (next time .002 etc) before pasting in server.jar (only for symbolic linking).

4 If you call the script server.sh you will probably need to issue the following command “chmod +x server.sh” (prefixed with sudo if you are not logged in with root access to the Pi).

6 the script means you don’t have to reboot the Pi but you could do if you wished. The script includes this line "echo “Usage: $0 { start | stop | restart | status }” so you can call the script with these self explanatory arguments.

7 I think the COMMAND line for you (without symbolic linking) and assuming you used the default dataFolder would be:

COMMAND=“java -jar /home/pi/server-0.17.2.jar -dataFolder /home/pi/Blynk”

1 Like

Ok, if your stuff in is in /home/pi, is the Blynk jar file there too?

You can do as follows to create the script. It depends a bit on your OS, but I’m assuming you run Raspbian? Behind the command I’ll put in brackets what the command does, for your convenience :wink:

Put the script on the server

cd /home/pi
hostname~ # ln -s server-0.17.x.jar server.jar {this makes a link to the current server jar file}
hostname~ # touch server.sh {this creates the script file}
hostname~ # chmod +x server.sh {this makes the script executable on Linux, as Costas mentions too}
hostname~ # nano server.sh {this executes the editor to put the script in}

So, with nano started, you can copy/paste the script to the server.sh file.

Now you need to edit your COMMAND var. For you it would be something like:

COMMAND="/prefer/full/path/here/to/java -jar /home/pi/server.jar -dataFolder
/data/folder/here" {of course with correct paths for data folder and java link. Java should be in your PATH variable, but I still like it to be the full path, just in case ;)

Now press CTRL-X to exit and Y to save the script.

Now you can run the script with the parameters:

hostname~ # ./server.sh start

That’s basically it to get it running. The next server upgrade you can download the new jar file and:

hostname~ # rm server.jar
hostname~ # ln -s new-server.jar server.jar

And run the script with the restart parameter :slight_smile:

From this you can see the server.jar is actually a link:

OpenELEC:~/blynk # ls -ltha
total 38738
drwxr-xr-x   14 root     root        1.0K Aug 27 16:57 ..
drwxr-xr-x    5 root     root        1.0K Aug 27 16:28 static
drwxr-xr-x    4 root     root        1.0K Aug 27 16:27 .
lrwxrwxrwx    1 root     root          17 Aug 27 16:27 server.jar -> server-0.17.2.jar
-rw-r--r--    1 root     root       13.7M Aug 27 16:27 server-0.17.2.jar
-rw-r--r--    1 root     root       12.5M Aug 10 06:52 server-0.17.0.jar

I have tried it on one of my Pi’s and it all checks out but you might find you need to manually kill your running server the first time without the script.

If you don’t like the weird command line for running scripts you can copy “server.sh” to just “server” and then you can use the following commands (sh just replaces ./):

sh server start
sh server status
sh server restart
sh server stop

I should add that removing file extensions is not good form but just like with running python scripts it saves a few more keystrokes.

1 Like

ok, i am almost crying, but his is as far as i got:

pi@raspberrypi:~ $ cd /home/pi
pi@raspberrypi:~ $ ce /home
bash: ce: command not found
pi@raspberrypi:~ $ cd /home
pi@raspberrypi:/home $ cd /pi
bash: cd: /pi: No such file or directory
pi@raspberrypi:/home $ sudo cd /pi
sudo: cd: command not found
pi@raspberrypi:/home $ cd /pi
bash: cd: /pi: No such file or directory
pi@raspberrypi:/home $ cd
pi@raspberrypi:~ $ sudo cd /home
sudo: cd: command not found
pi@raspberrypi:~ $ 

is it because i am using VNC viewer to remote in to my Pi?

EDIT:

so i did the @Dmitriy method:

pi@raspberrypi:~ $ ps -aux | grep java
root       380  3.0 15.4 227236 68588 ?        Sl   Aug27 102:00 java -jar /home/pi/server-0.17.0.jar -dataFolder /home/pi/Blynk
pi       22292  0.0  0.4   4272  2000 pts/0    S+   11:25   0:00 grep --color=auto java
pi@raspberrypi:~ $ sudo kill 380
pi@raspberrypi:~ $ ps -aux | grep java
pi       22307  0.0  0.4   4268  1972 pts/0    S+   11:25   0:00 grep --color=auto java
pi@raspberrypi:~ $ sudo java -jar server-0.17.2.jar -dataFolder /home/pi/Blynk

then it said:

Blynk Server successfully started.
All server output is stored in folder '/home/pi/./logs' file.

then i changed the crontab thingy and it seems to have worked OK.

is changing these values is only possible from Hardware side to change ?? is there any plane to interface it to restful and websockets ?

Yes.

Sure. As usual we do simple version. Waiting for feedback and adding more and more.

1 Like

It’s way easier to use something like Putty to SSH into your Pi box.

How far does your experience with the command line go? I know I’m really old and I grew up with it … so it’s a little more easy for me to use. If you want some more detailed Linux knowledge passed, please send me a PM. I don’t think it’s appropriate to do that here, since it’s totally not Blynk related, but I’d be willing to help you get on track of course :slight_smile:

@Dave1829 you might also want to look at WinScp which also has a Command line facility.

@Dmitriy I just updated the Android app to 1.14.0 and now app is force closing!

Did I do something wrong?

@Dave1829 1.14.0 is working for me.

Do you use local server? Is it updated to 0.17.2?

Yes, i updated that last night, see above!

I thought i needed to update both to get the new app features?

Correct. We just published possible fix for you. I think it should appear in store within 1 hour. Let me know if new version helped you.

1 Like