Start in headless mode

Hi, in the process to porting Syncthing to OpenWrt (OS for embedded devices) I’m facing massive CPU consumption for the first 60 seconds after starting Syncthing. Disabling the GUI via config speeds up startup process without the CPU peak. As Syncthing generates the configuration on first startup, it seams not feasible to start it it, wait for config creation, kill it, parse XML and disable the GUI, restart it. Instead, would be nice to have a arg like -headless which disables the GUI.

A more general approach, would it be possible to get rid of all UI code and make Syncthing only controllable via config and maybe stcli? Storage/RAM/CPU is precious on some embedded devices :slight_smile: Best

1 Like

stcli uses the REST Api (afaik) which is the GUI.

Without the GUI the only way to “control” syncthing is by killing it, editing the config file and starting it again.

Hey, yea I just figured that and was about to ask for another solution :confused:

I remember somewhere that it’s possible to disable some initial startup scans which are used to show progress in the web interface, don’t remember any details and can’t find it anymore. Maybe that would improve the startup delay?

I think that param / env var was removed, as most of the stuff that needed to be calculated on startup is now stored in the DB and just loaded on startup.

Thanks, that’s good to know. I’ll look for other reasons what makes the CPU load so high without even syncthing anything…

The GUI being enabled or not should have no effect on the startup time, unless you are somehow not persisting the HTTPS certificate between starts. Regenerating that might be expensive.

Run with -verbose, look at the log entries, and correlate with when that minute of CPU usage kicks in.

Syncthing will also be somewhat useless without the GUI.

Good, I’ll keep you updated on the results!

Bad news I guess, the CPU usage raises to 100% before the first message is printed:

root@v2:~# /usr/bin/syncthing -verbose -gui-address= -home=/etc/syncthing/
[monitor] 09:44:56 INFO: Starting syncthing
[FULN5] 09:45:06 INFO: syncthing v0.14.48 "Dysprosium Dragonfly" (go1.10 linux-mipsle) openwrt@openwrt 2018-06-27 20:11:06 UTC
[FULN5] 09:45:06 INFO: My ID: foobar
[FULN5] 09:45:07 INFO: Single thread SHA256 performance is 3.7 MB/s using crypto/sha256 (3.7 MB/s using minio/sha256-simd).
[FULN5] 09:45:07 VERBOSE: Starting up (/etc/syncthing/)
[FULN5] 09:45:09 INFO: Hashing performance is 3.34 MB/s
[FULN5] 09:45:09 INFO: Overall send rate is unlimited, receive rate is unlimited
[FULN5] 09:45:09 INFO: Rate limits do not apply to LAN connections
[FULN5] 09:45:09 INFO: Using discovery server
[FULN5] 09:45:09 INFO: Using discovery server
[FULN5] 09:45:09 INFO: Using discovery server
[FULN5] 09:45:09 INFO: TCP listener ([::]:22000) starting
[FULN5] 09:45:09 INFO: Relay listener (dynamic+ starting
[FULN5] 09:45:09 INFO: GUI and API listening on [::]:8384
[FULN5] 09:45:09 INFO: Access the GUI via the following URL:
[FULN5] 09:45:09 INFO: Device foobar is "v2" at [dynamic]
[FULN5] 09:45:09 WARNING: Syncthing should not run as a privileged or system user. Please consider using a normal user account.
[FULN5] 09:45:09 VERBOSE: Startup complete
[FULN5] 09:45:19 INFO: Detected 1 NAT service

EDIT: the used ID is just for testing anyway, it’s shown in the history :stuck_out_tongue:

Before which message, specifically? There are no 60s accounted for above. There are 10s between “starting” and the version output - is that what you mean?

One thing you can try is export STHASHING=standard before starting. That disables some early benchmarking, which should only take a couple of seconds.