Fix cloudflared service with preStart script to ensure log directory and file exist

This commit is contained in:
Julian Sutter 2025-07-18 22:09:02 -07:00
parent 6419e44222
commit 0c2f06bd72

View file

@ -26,6 +26,13 @@ in {
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
# Create directory for log files
preStart = ''
mkdir -p "$(dirname ${tunnel.logPath})"
touch ${tunnel.logPath}
chmod 644 ${tunnel.logPath}
'';
serviceConfig = {
ExecStart = "${pkgs.cloudflared}/bin/cloudflared access tcp --hostname ${tunnel.remoteHost} --url ${tunnel.remoteTarget} --port ${toString tunnel.localBindPort} --logfile ${tunnel.logPath}";
Restart = "always";