GPSD not starting automatically

Yes, you already think you know the answer looking at the topic title, but perhaps it's not the obvious one!

Raspbian Jessie, with current updates. gpsd installed and working from the default serial port. Almost.

When first booting the RPi gpsd does /not/ autostart in spite of "-n" being present in the options. This used to work under Wheezy.

So I enter: "sudo service gpsd restart" and gpsd is then running as normal. I guess I'm missing something obvious, but what? Any thoughts about what the problem might be, and how to proceed with further diagnosis?

Thanks!

--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor
Loading thread data ...

Are you sure the script is being executed at start up?

Perhaps include a diagnostic message output to a temporary file to confirm execution?

Assuming you can find the script that is supposed to start the process, of course.

Systemd joys await me shortly.

Cheers

Dave R

--
Windows 8.1 on PCSpecialist box
Reply to
David

Where are these options of which you speak?

Is the -n option present in both the ExecStart and ExecReload lines in the [Service] section of gpsd.service?

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
 Click to see the full signature
Reply to
Martin Gregorie

The options are entered by manually editing /etc/default/gpsd in Jessie. I have:

START_DAEMON="true" GPSD_OPTIONS="-n /dev/ttyAMA0" DEVICES="" USBAUTO="false" GPSD_SOCKET="/var/run/gpsd.sock"

although I've also tried:

START_DAEMON="true" GPSD_OPTIONS="-n" DEVICES="/dev/ttyAMA0" USBAUTO="false" GPSD_SOCKET="/var/run/gpsd.sock"

Where might I find gpsd.service? That's not a file I am familiar with at all, but I'd like to check it.

--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor

On 02/03/2016 12:22, David wrote: []

Thanks, Dave. The script is a configuration one, rather than a start-up one - see my other post. With Jessie I have no idea where the actual start-up script lives.

I'm trying to get this figured out so that I can put it on my Web pages to help others.

--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor

Not having gpsd installed, I looked at crond.service to check the keynames in the [Service] section. There were copies in /etc/systemd/system/* and / usr/lib/systemd/system - if its not in either, try "locate gpsd.service".

For an explanation of the content of .service files, try

man 5 systemd.service

which mainly covers the [Service] section of a .service file and contains references to other manpages which cover the contents of the [Unit] and [Install] sections as well as other material.

One thing I should have asked earlier: what does "systemctl status gpsd" show?

The reason I ask is that by default systemd daemons are disabled when they're first installed - under Fedora anyway. This means that although you can start them with 'systemctl start servicename', they will not start automatically at boot time until you've run "systemctl enable servicename".

This is no different from sysVinit, where you had to do exactly the same using syscontrol whenever you installed a new daemon in order to tell it which runlevels it should be active at.

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
 Click to see the full signature
Reply to
Martin Gregorie

most things are no controlled by the systemctl command

systemctl status Show the status of service systemctl start Starts Service systemctl stop stops service systemctl enable enables service @ startup systemctl disable disables service @ startup systemctl is-enabled Checks if service is enabled or disabled

this should help with your problem (I Hope)

--
A penny saved is a penny taxed.
Reply to
alister

Martin,

Thanks for all that! I located the service file here:

/lib/systemd/system/gpsd.service

It contains:

[Unit] Description=GPS (Global Positioning System) Daemon Requires=gpsd.socket [Service] EnvironmentFile=-/etc/default/gpsd ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS $DEVICES [Install] Also=gpsd.socket

I don't see why that wouldn't start the service, but I really know very little at this level.

Again the issue is:

- reboot

- gpsd service does/not/ start

- run cgps and exit

- gosd service is started

It's just as if the "-n" parameter is being ignored.

--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor

Dzieki, David, za post o tresci:

Well, this unit file doesn't have entries required for enabling autostart. I guess because socket-activation is used ? it means GPSD is started on-demand, when first client connects. The appearance of ?gpsd.socket? strongly suggest so.

Following confirms that gpsd is started on client access:

It's not ignored, gpsd is not started at boot so it can't intepret this option or not. Your distribution decided to configure GPSD to be started on-demand. There is probably some reasoning for it, especially that there are no means to easily enable on-boot GPSD startup (using systemctl enable). Of course you can still manually override those decisions and start gpsd on boot by issuing:

ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/

--
Tomasz   .. oo o.   oo o. .o   .o o. o. oo o.   .. 
Torcz    .. .o .o   .o .o oo   oo .o .. .. oo   oo 
 Click to see the full signature
Reply to
Tomasz Torcz

As I also asked, what does:

systemctl status gpsd

show? The second line of output should show something like:

Loaded: loaded (/usr/lib/systemd/system/gpsd.service; enabled; ... =======

The word (underlined) following the pathname of the service file should be either 'enabled' or 'disabled'. IME the latter is the initial setting when you install a new package: not surprising really, since you usually don't want to run a daemon before you've configured it. Anyway, once its configured and tested using:

systemctl start/stop/status gpsd

commands and you're happy with what its doing, then you leave gpsd running and execute:

systemctl enable gpsd

to tell systemd that from now on this service/daemon should be started when the system is (re)booted. This applies to any and all daemons you want to have running all the time. Needless to say, if you no longer want the daemon to start automatically, prevent it being started on boot-up with:

systemctl disable gpsd

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
 Click to see the full signature
Reply to
Martin Gregorie

On 04/03/2016 17:14, Tomasz Torcz wrote: []

Thanks for that, Tomasz, works perfectly.

Martin, apologies for not answering the status question. I'm afraid I can't now recall what the status was, but I now get a multi-line output. Previously it was a single word.

I do appreciate everyone's help, and this is now written up on my Web site for anyone to use.

--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor

David,

Thank you so very much for your web site. It worked great for me over the past couple of days as I built a RPi with Adafruit GPS Hat -- except for starting gpsd on boot.

I finally found that running the following command from the "start)" section of /etc/init.d/ntp did the trick:

gpspipe -d -r -l -n 1 -o /dev/null

It waits 10 seconds, then accesses gpsd to read one NEMA sentence, then exits.

Seems to work, but is a bit of a kludge. I like the solution posted by Tomasz Torc much better.

Again, thanks for your great web site.

Tomasz Torc -- thanks for your solution!

Mark

Reply to
markallenshell

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.