Running Resilio Connect Proxy on Linux at boot, restart on failure
On a Linux OS there are a few ways to launch Resilio Connect Proxy process at system boot as also restart it if it stops for a reason.
At least one first run of the proxy process is required before relying on the startup scripts below.
Linux Systemd Service
(recommended)
Create file /lib/systemd/system/resilio-connect-proxy.service
(superuser's
permissions required) with the following content.
[Unit]
Description=Resilio Connect Proxy Service
Documentation=https://connect.resilio.com
After=network.target network-online.target
[Service]
Type=forking
UMask=0002
Restart=always
PermissionsStartOnly=true
User=<some_user>
Group=<some_group>
PIDFile=/home/<some_user>/resilio-connect-proxy/.sync/sync.pid
ExecStart=/home/<some_user>/resilio-connect-proxy/rslproxy --proxy --storage /home/<some_user>/resilio-connect-proxy/.sync
[Install]
WantedBy=multi-user.target
Replace <some_user>
and <some_group>
with the user and group that will run
the proxy process. Put the valid path to the binary (for example
/usr/bin/proxy
) to ExecStart
directive. Make sure that the path to .sync
directory in this service file also points to the true proxy's storage path.
Save the file and run command
sudo systemctl daemon-reload
To start the service run command
sudo systemctl start resilio-connect-proxy.service
To add service to autostart run command
sudo systemctl enable resilio-connect-proxy.service
Using Supervisor
Install Supervisor:
sudo apt install supervisor
Edit its config file located here: /etc/supervisor/supervisord.conf
Add the
following lines to the config to make Supervisor to take care the proxy:
[program:worker]
command=/home/<some_user>/resilio-connect-proxy/rslproxy --storage /home/<some_user>/resilio-connect-proxy/.sync
stdout_logfile=/home/<some_user>/resilio-connect-proxy/stdout.log
autostart=true
autorestart=true
user=<some_user>
redirect_stderr=true
stopsignal=KILL
numprocs=1
Replace
/etc/init.d/supervisor restart
or
sudo systemctl restart supervisord
Supervisor official docs are here.
Docker
Install Docker:
sudo apt install docker.io
Download proxy executable file and create Dockerfile
beside it with the
following content:
FROM ubuntu:18.04
ARG USER=resilio
ARG GROUP=resilio
ARG USERID=555
ARG GROUPID=555
RUN apt-get update && \
apt-get install -y libnuma1 libnuma-dev
RUN groupadd -g ${GROUPID} ${GROUP} && \
useradd -m -u ${USERID} -g ${GROUPID} ${USER}
WORKDIR /home/${USER}
COPY rslproxy .
RUN mkdir .sync
RUN chown -R ${USER}:${GROUP} /home/${USER}
USER ${USER}
ENTRYPOINT ["./rslproxy"]
CMD ["--nodaemon", "--log", "/home/resilio/.sync/proxy.log", "--storage", "/home/resilio/.sync"]
Build image:
sudo docker build -t resilio-connect-proxy .
Create storage folder and set permissions:
mkdir storage && sudo chown -R 555:555 ./storage
And run the container from the image in host
network mode:
sudo docker run -d --network host --restart always -v $(pwd)/storage:/home/resilio/.sync resilio-connect-proxy
Docker official docs are here
Crontab
The easiest is to add a cron task. The minimal command is below. Every minute
it will check for the running process and start it if necessary. In Terminal
run command crontab -e
. Enter the command below, be sure to uncomment the
line (remove #)
*/1 * * * * ps -A | grep rslproxy || /home/admin/proxy/rslproxy --storage /home/admin/proxy/.sync
Use the valid path to rslproxy binary instead of /home/admin/proxy
use the correct path to .sync storage folder. By default it’s created in current directory (pwd) on first launch. Since cron is started from a different directory, full path to .sync shall be specified
Save the file. It’s important to at least once launch the proxy with the configuration file and connect it to the Management Console before going with the cronjob.
This option is applicable if there is no regular agent (rslagent) running on this system at the same time.