Fix cloudflared service to ensure it runs persistently

This commit is contained in:
Julian Sutter 2025-07-18 22:11:38 -07:00
parent 0c2f06bd72
commit 8646e5a9f8

View file

@ -35,10 +35,19 @@ in {
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.cloudflared}/bin/cloudflared access tcp --hostname ${tunnel.remoteHost} --url ${tunnel.remoteTarget} --port ${toString tunnel.localBindPort} --logfile ${tunnel.logPath}"; ExecStart = "${pkgs.cloudflared}/bin/cloudflared access tcp --hostname ${tunnel.remoteHost} --url ${tunnel.remoteTarget} --port ${toString tunnel.localBindPort} --logfile ${tunnel.logPath}";
# The key setting to ensure the service stays running
Type = "simple";
Restart = "always"; Restart = "always";
RestartSec = "5s"; RestartSec = "5s";
User = "root"; # Configure service to wait for network
Group = "root"; After = [ "network-online.target" ];
Wants = [ "network-online.target" ];
# Run as dedicated user for better security
DynamicUser = true;
# Configure systemd runtime directory
RuntimeDirectory = "cloudflared";
RuntimeDirectoryMode = "0700";
# Standard outputs
StandardOutput = "journal"; StandardOutput = "journal";
StandardError = "journal"; StandardError = "journal";
}; };