Posted on

Raspberry Pi – Running Spy Server as a service

 

  • Updated 8th Aug 2018 to add a start-up delay to the rtlsdr.service file. This is to ensure that an IP address has been allocated before the Spy Server starts.

The excellent Airspy Spy Server can easily be used as a service using SYSTEMD under Linux. This is a much better way to autostart the server as it gives you the facility to stop/start/check status of the server at any time. I’ve used this facility in my latest Spy Server SD card so you can switch between receiver types without having to reboot the Pi.

Running Spy Server as a Service

The first step is to create a new file called spyserver.service and save it in /etc/systemd/system/.

The simplest way to do this is using nano as follows:

sudo nano /etc/systemd/system/spyserver.service

Now enter the following text into the file and save it (Ctl x y Enter):

[Unit]

Description=Spy Server

Wants=network-online.target
After=network-online.target

[Service]

ExecStartPre=/bin/sleep 15

ExecStart=/home/pi/./spyserver spyserver.config

WorkingDirectory=/home/pi/

StandardOutput=inherit

StandardError=inherit

Restart=always

User=pi

[Install]

WantedBy=multi-user.target


You can now start, stop and check the status of Spy Server with the following commands:

sudo systemctl start spyserver.service

sudo systemctl stop spyserver.service

sudo systemctl status spyserver.service

The following command will activate the service to automatically start at boot time:

sudo systemctl enable spyserver.service

That’s it!

Mike – G4WNC

5 thoughts on “Raspberry Pi – Running Spy Server as a service

  1. Thanks a lot for the page Raspberry Pi – Running Spy Server as a service
    its working great with Ayrspy mini on a Raspberry Pi 3 +

    for me it did not autostart the service until i googled and found there is an error
    on your page

    wantedBy=multi-user.target must be WantedBy=multi-user.target

    nice work thank you

    1. Hi Fernando,

      Glad you’ve found it useful and thanks for spotting that typo. I’ll correct it now.

      Mike – G4WNC

  2. Mike, with the “Update All” command, will only Linux OS updated or also to the newest Spy server version?

    73 Chris DL5NAM

    1. Hi Chris,

      Apologies for the confusion but ‘Update All’ only updates the spy server code and its associated drivers, i.e. rtl-sdr, airspy and airspy HF+.

      If you want to update the OS, you can use the normal sudo apt update && sudo apt -y upgrade.

      Regards,

      Mike – G4WNC

      1. Mike thanks info, sounds good for me if Spy Server updated with this task.

        OS updated is not so important 🙂

        73 Chris DL5NAM

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.