Hello folks,
I’m setting up my own Blynk “local” server, by the way, I am using this provider: linode.com, 5 Dollars per moth, so far seems to be good, they offer may linux distros, I picked Ubuntu.
Anyway, my blynk server stops randomly, it just dies. Of course, this is not good. So I set up a blynk.service file located in /etc/systemd/system folder, here is a copy just in case:
[Unit]
Description=My Blynk Server
Requires=network-online.target
After=network.target
#After=network.target network-online.target multi-user.target
[Service]
Type=simple
# Another Type option: forking
User=root
WorkingDirectory=/home/Blynk/
ExecStart=/usr/bin/java -jar server-0.41.0-java8.jar -dataFolder /home/pi/Blynk**
Restart=always
Restart=on-failure
RestartSec=10
# Other Restart options: or always, on-abort, etc
[Install]
WantedBy=multi-user.target
The part that I want to point out is the line starting with ExecSart . The java executable file is located here, I scratched my head for a while because when I executed this command: systemctl restart blynk.service, I was getting errors because I pointed the java file to the wrong location.
This is what I get now:
Nov 22 03:12:53 AlexHost java[1083]: Blynk Server 0.41.1-SNAPSHOT successfully started.
Nov 22 03:12:53 AlexHost java[1083]: All server output is stored in folder '/home/Blynk/logs' file.
root@AlexHost:/etc/systemd/system#
Hopefully, this will solve the problem.
UPDATE: This has solved my problem. The Blynk server has not died since I installed this file, and that was basically the idea, if the server dies for whatever reason, this file monitors that, and automatically will reinitialize the server. The server has been up and running for 48+ hours continuously. It did not do that before.
By the way, dont use rc.local, is old school, deprecated, Ubuntu doesn’t even include it anymore.
One final note, if the server is rebooted, add this line to your crontab, this will automatically kick the server up and running.
@reboot java -jar /home/Blynk/server-0.41.0-java8.jar -dataFolder /home/Blynk/MyServer
This other line will adjust your server’s time to your local time zone.
@reboot cp /usr/share/zoneinfo/America/MyCity /etc/localtime
Assuming, you live in America, change MyCity to the city you live in.