Traccar server on Raspberry Pi 4

Raoula year ago

This is the result:

raoul@Raspberry:/opt/traccar$ sudo java -jar /opt/traccar/tracker-server.jar /opt/traccar/conf/traccar.xml
[sudo] password for raoul: 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/opt/traccar/lib/guice-4.2.3.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Raoula year ago

...and the process in the Terminal continues running...

Anton Tananaeva year ago

Sounds like it's working.

Raoula year ago

...and the process in the Terminal continues running...

AlfSollia year ago

Raoul, at this point (while the process in the terminal continues running...) you should be able to access the traccar web interface on your raspberry's IP:8082

AlfSollia year ago

Also, if you can't get it to run with systemd (systemctl start traccar) but this way works, you could run the java command with "screen" in front of it.
That'll give you a virtual terminal that you can close and disconnect from the Pi, keeping the java process running in the background.

If you don't have screen, "apt-get install screen" will solve that issue for you.
You can actually run any linux command with the word "screen" in front of it, and it'll be a background process you can re-attach at a later point if you with with "screen -r"

It'll keep running even if you close your ssh sesssion. But to cleanly detach any process running under screen, press CTRL + A then D. (with CTRL still pressed)

CTRL + A then K will kill the process, should you need it instead. As well as CtRL + C

Raoula year ago

Anton, Richard and AlfSolli: thanks a lot for your (patient) support!!

I started about one year ago with my GPS experiences. I tried the platforms DAGPS (simple interface with a lot of bugs), myGPS and GPSWOX. Later on I discovered Traccar. To my opinion far out the best for my 3 GPS devices in my (hobby) applications.

I started Traccar on my Windows laptop, later I installed it with Linux on a very old laptop and later, regarding the power consumption of my old laptop, I installed it on my Raspberry Pi 4 with a Linux Ubuntu Desktop 20.10 version.
It is running flawlessly now.
One thing remains: the traccar server does not automatically start up after a restart of my Raspberry. But I remember that I saw some remark about that somewhere on the forum.
(Any suggestions are welcome!!)

It must be possible to put some instruction in the start up program of the Raspberry??

If not, I will solve it wit a simple UPS (Not very elegant!)

AlfSollia year ago

You're welcome.
Did you manage to start with using systemd ? In that case it should be as easy as "systemctl enable traccar.service"

If not, there are plenty of options;

  • Use any of the init scripts to call your traccar start command / script , possibly with screen involved to not hang the startup prompt, or using & at the end of the command to put it in the background.
  • Create a script that checks if traccar is running, and if not, start it. Put this script in a 5 minute interval in crontab.
  • I guess a lot more, but I'm having a stressed out day at the moment, so I'm gonna let you google my hints. You'll learn a lot more then too. :)
Raoula year ago

Hi AlfSolli,
This morning the system was still running. I was also able to restart the server (manually) after a restart of my Raspberry.

After that I made a "big mistake". After login in with admin, admin, I made a typing error in the password and logged out.
After various trials, I decided to install the traccar server again. Unfortunately this did not work. (The system kept remembering me with the wrong password).

Therefore I installed Linux Desktop Ubuntu 20.10 again.
After the usual instructions, the outcome was that in the correct folder (/opt/traccar/jre/bin) the java command was not found.

Therefore I installed java with the following command:
sudo apt install default-jre

After this I could install the traccar server again by means of:
raoul@Raspberry:/opt/traccar$ sudo java -jar /opt/traccar/tracker-server.jar /opt/traccar/conf/traccar.xml

I am happy that all steps I made before are now understandable to me and especially repeatable.

I have no experience (yet) with init scripts or the use of systemd therefore I studied the sysytemctl commands today.
Some remarkable issues: the traccar system remains in the "actvating" mode. How come? Is it because I closed the Terminal while it was still busy?
See:
raoul@Raspberry:~$ systemctl is-active traccar
activating

The "sudo systemctl start traccar" command does not work.
Therefore I started the tracker-server.jar file manually by means of the (self installed) java launcher.

And the "sudo systemctl enable traccar" does not work either to start automatically at reboot.
However the command:
raoul@Raspberry:~$ systemctl is-enabled traccar
enabled
says that the system already is enabled.

So that will leave only the option to start an init script I gues. But that will take another (couple of?) day(s?).

Which time zone are you in?
I am in the Netherlands.

AlfSollia year ago

Hi.
Shit luck :) You could have replaced the password hash in the database directly, but I'm not sure which hashing scheme is used. But nevermind, since you already reinstalled, it's not an issue.

Please check, as root, "whereis java" <- This command should tell you where your java executable is. It's probably different than the one in /opt/traccar/jre/bin .

Secondly, please check the systemd script for traccar. It's in /etc/systemd/system/traccar.service.

My content shows this:

[Unit]
Description=traccar
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/traccar
ExecStart=/opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml
SyslogIdentifier=traccar
SuccessExitStatus=143
WatchdogSec=600
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

If you replace the ExecStart line with the result from "whereis java" and leave the rest of the line intact, it might work.
(OR, just "java" instead of the whole path to /opt/traccar/jre/bin/ or whatever your whereis java command returns) Try both if the first doesn't work please.
Would you test and let me know?

Ps; I'm in GMT+1 (Norway)

Raoula year ago

Thanks a lot!! Tomorrow afternoon I can play wit this again.
Today I studied systemctl and init scripts. So your answer already shows some recognizable items.
One thing which worries me is the traccar status: "activating".
I would expect "active".
Is this of any importance?

AlfSollia year ago

It should definitively be 'active'.
Probably the command systemd tries to start the service does not return the proper (or anything) that systemd recognizes, or it's stuck for some reason. Either way, starting traccar should be fairly quick, so systemctl is-active should return 'active' pretty quick after startup, if successful.

Try editing the traccar.service file, and let's see where that gets us. :)

Raoula year ago

Now I know why the traccar.service remains in the "activating" status.
At the start up I gave the command "sudo systemctl start traccar" but that did not work. Therefore I started traccar manually by means of the self installed java version. Thereafter traccar starts to run and remains running.
When I do a check thereafter on the traccar status it says "activating". In other words: the "sudo systemctl start traccar" continuous to start-up traccar and the system does not see that it is already running.

The proof of this is when I enter the command "sudo systemctl stop traccar. Thereafter traccar remains running but the "systemctl is-active traccar" says then that traccar is "inactive".

Raoula year ago

Next step:

I gave the command:

raoul@Raspberry:~$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

To my opinion that gives 2 locations: (the last one probably is not an application launcher?)
As you know I installed one package my selves and, I guess, the other one probably was included in the traccar download.
Now the question is: which one is the correct path to the non-self-installed java?

(In the meanwhile I have given the commands:
sudo apt-get update
sudo apt-get upgrade
both were successful but did not change anything in the "sudo systemctl start traccar" command)

When I look into the traccar.service file I see indeed the following:
[Unit]
Description=traccar
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/traccar
ExecStart=/opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml
SyslogIdentifier=traccar
SuccessExitStatus=143
WatchdogSec=600
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

How to proceed now?
Can I just change the traccar.service and save it?
And which is the correct path to be used? (usr/bin/java or usr/share/java?)

And of course I have to save the modified file somewhere else in case I will do in future another traccar download installation.

Raoula year ago

Google says that the boot files are installed under /usr/bin. Correct?
So the usr/bin/java path should be the correct one?