PlatformIO Community

[howto] Remote agent systemd service

If you’re looking to to run the remote agent on linux (say, a pi) you can run it as a service instead of having to login, start it, background it, logout

To do so install platformio via the docs and create the following file: /etc/systemd/system/pio-remote.service with:

Description=pio remote agent

# change to your user of choice

ExecStart=/usr/local/bin/platformio remote agent start


This assumes the path to platformio was installed to the system python (not a great idea if you plan on using the machine for anything else) and will be different if you installed into virtualenv or pip --user, run “which platformio” to find out.

Next run “sudo systemctl daemon-reload && sudo systemctl enable pio-remote”, make sure you have logged in with “platformio account login”, and finally run “sudo systemctl start pio-remote”

If all is well you should see it running with “sudo systemctl status pio-remote”

pi@pi-platformio:~ $ sudo systemctl status pio-remote.service                                                                                                                                                                                                  
● pio-remote.service - pio remote agent
   Loaded: loaded (/etc/systemd/system/pio-remote.service; enabled)
   Active: active (running) since Mon 2017-04-10 00:21:14 UTC; 13min ago
 Main PID: 701 (platformio)
   CGroup: /system.slice/pio-remote.service
           ├─701 /usr/bin/python /usr/local/bin/platformio remote agent start
           └─822 /home/pi/.platformio/packages/tool-pioplus/pioplus remote agent start

Apr 10 00:21:14 pi-platformio systemd[1]: Starting pio remote agent...
Apr 10 00:21:14 pi-platformio systemd[1]: Started pio remote agent.
Apr 10 00:21:18 pi-platformio platformio[701]: PlatformIO Plus ( v0.7.3
Apr 10 00:21:18 pi-platformio platformio[701]: 2017-04-10 00:21:18 [info] Name: pi-platformio
Apr 10 00:21:18 pi-platformio platformio[701]: 2017-04-10 00:21:18 [info] Connecting to PIO Remote Cloud
Apr 10 00:21:19 pi-platformio platformio[701]: 2017-04-10 00:21:19 [info] Successfully connected
Apr 10 00:21:19 pi-platformio platformio[701]: 2017-04-10 00:21:19 [info] Authenticating
Apr 10 00:21:20 pi-platformio platformio[701]: 2017-04-10 00:21:20 [info] Successfully authorized
1 Like

Thanks a lot for your snippet. We will add later special command pio remote agent autostart yes/no which will create service config automatically depending on OS type/distro.

Please note that account session is valid for 2 weeks. You will need to re-login again manually. To avoid this issue, please export PLATFORMIO_AUTH_TOKEN environment variable before agent start.

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

I know this is an old topic, but apparently Google send me here. So if others are looking for the same solution as me I’ll post my startup-script here:

Description=Run platformio remote agent

Environment="PLATFORMIO_AUTH_TOKEN=<insert your token here>"
WorkingDirectory=/home/<your user name>/.platformio/penv
ExecStart=/home/<your user name>/.platformio/penv/bin/pio remote agent start --serve-in-foreground
User=<your user name>


adding to an old topic but it’s very important to set the RestartSec parameter to avoid DDOSing the platformio login servers

3 seconds
5 minutes

1 Like