Here some tips to create syncthing test environments.
Multiple Test Instances
You can start multiple instances on the same machine. Every instance must used separate listening ports, e.g.: 22001
, 22002
etc. Add all nodes with address/port e.g.: 127.0.0.1:2200x
(local discovery doesn’t work within the same host).
To do this:
- Set a different home directory for every instance
- Start one instance and change settings, then start next instance etc.
Linux
Here a simple script to startup multiple instance with different home directories:
#!/bin/bash
# Change the path to syncthing binary here:
SYNCTHING_BIN=/home/syncthing/bin/syncthing
read -n1 -p "Start number? [1,2,3...]" NUMBER
echo
BASE_DIR=~/syncthing_test/instance${NUMBER}/
mkdir -p $BASE_DIR
(
set -x
HOME=${BASE_DIR}
${SYNCTHING_BIN} -home=${BASE_DIR}\syncthing_configs
)
Start the script and enter 1
, setup the instance. Start in a other terminal, enter 2
, etc.
You will get the following filesystem structure:
- ~/syncthing_test/
- instance1/
- syncthing_configs/config.xml
- instance2/
- syncthing_configs/config.xml
- instance1/
e.g:
Windows
Here a batch file that starts two instances at once:
@echo off
prompt -$G
cd /d "%~dp0"
set syncthing_exe=D:\path\to\syncthing.exe
title syncthing test%1
if "%1"=="" (
echo on
@echo.
@echo Start instance 01
start cmd.exe /K "%~0" 01
@echo.
@echo Start instance 02
start cmd.exe /K "%~0" 02
@echo off
echo.
echo This window can be closed.
pause
goto:eof
)
REM Start one instance
echo on
set HOMEDRIVE=D:
set HOMEPATH=\synthing_test\instance%1
set USERPROFILE=%HOMEDRIVE%%HOMEPATH%
set APPDATA=%USERPROFILE%\Roaming
set LOCALAPPDATA=%USERPROFILE%\Local
set COMPUTERNAME=%USERDOMAIN%_test%1
set USERDOMAIN_ROAMINGPROFILE=%USERDOMAIN%_test%1
set USERDOMAIN=%USERDOMAIN%_test%1
%syncthing_exe%
@pause
You must set syncthing_exe and you can change HOMEDRIVE and the start folder of HOMEPATH for your needs.
To cleanup the default Sync repository, adapt this batch:
@echo off
prompt -$G
title %0
set BASE=D:\synthing_test\instance
echo on
rmdir /q /s %BASE%01\Sync
del %BASE%01\Local\Syncthing\*.gz
@echo.
rmdir /q /s %BASE%02\Sync
del %BASE%02\Local\Syncthing\*.gz
@pause