From fd3c5f47087cf33fd575ab84124d0a956cf4538b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 20 Sep 2026 12:52:24 +0200 Subject: [PATCH] setup cron for background jobs --- nix/image/bootstrap | 3 ++- nix/image/configs.nix | 1 - nix/image/configs/cron.d/nc | 2 ++ nix/image/configs/oc-cron.conf | 2 -- nix/image/configs/supervisor/enabled/cron.conf | 2 ++ nix/image/scripts/nc-auto-config | 2 +- src/main.rs | 14 ++++++++++++++ 7 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 nix/image/configs/cron.d/nc delete mode 100644 nix/image/configs/oc-cron.conf create mode 100644 nix/image/configs/supervisor/enabled/cron.conf diff --git a/nix/image/bootstrap b/nix/image/bootstrap index 4e7e0f3..80a741b 100755 --- a/nix/image/bootstrap +++ b/nix/image/bootstrap @@ -2,7 +2,6 @@ touch /var/log/nginx/access.log touch /var/log/nginx/error.log -touch /var/log/cron/owncloud.log mkdir /config if not ("/config/php.ini" | path exists) { @@ -35,6 +34,7 @@ let dirs = [ let files = [ ["condition", "path"]; ["/", "/var/www/html/build/integration/composer.lock"], + ["/", "/var/log/cron/haze.log"] ] $dirs | each { |dir| @@ -88,6 +88,7 @@ if ("REDIS_TLS" in $env) { cp /etc/supervisor/redis-tls.conf /etc/supervisor/enabled/ } else { cp /etc/supervisor/redis-plain.conf /etc/supervisor/enabled/ + cp /etc/supervisor/redis-plain.conf /etc/supervisor/enabled/ } if ("BLACKFIRE_SERVER_ID" in $env) { diff --git a/nix/image/configs.nix b/nix/image/configs.nix index afa06c7..e563aa0 100644 --- a/nix/image/configs.nix +++ b/nix/image/configs.nix @@ -3,5 +3,4 @@ runCommand "configs" {} '' mkdir -p $out cp -r ${./configs} $out/etc chmod -R +w $out/etc - mkdir $out/etc/supervisor/enabled/ '' diff --git a/nix/image/configs/cron.d/nc b/nix/image/configs/cron.d/nc new file mode 100644 index 0000000..b9fb836 --- /dev/null +++ b/nix/image/configs/cron.d/nc @@ -0,0 +1,2 @@ +# m h dom mon dow user command +* * * * * haze php -f /var/www/html/cron.php -- -v >> /var/log/cron/haze.log 2>&1 diff --git a/nix/image/configs/oc-cron.conf b/nix/image/configs/oc-cron.conf deleted file mode 100644 index 81c6020..0000000 --- a/nix/image/configs/oc-cron.conf +++ /dev/null @@ -1,2 +0,0 @@ -# m h dom mon dow command -*/5 * * * * sudo -u haze php -f /var/www/html/cron.php >> /var/log/cron/haze.log 2>&1 diff --git a/nix/image/configs/supervisor/enabled/cron.conf b/nix/image/configs/supervisor/enabled/cron.conf new file mode 100644 index 0000000..9646598 --- /dev/null +++ b/nix/image/configs/supervisor/enabled/cron.conf @@ -0,0 +1,2 @@ +[program:cron] +command = crond -x sch -f diff --git a/nix/image/scripts/nc-auto-config b/nix/image/scripts/nc-auto-config index 674baaa..0cf9554 100755 --- a/nix/image/scripts/nc-auto-config +++ b/nix/image/scripts/nc-auto-config @@ -2,7 +2,7 @@ touch /var/log/nginx/access.log touch /var/log/nginx/error.log -touch /var/log/cron/owncloud.log +touch /var/log/cron/haze.log if ("/var/www/html/config/config.php" | path exists) { exit 0 diff --git a/src/main.rs b/src/main.rs index 54dbf97..2c01ce4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -616,6 +616,20 @@ async fn setup( ) .await?; } + cloud + .occ( + docker, + vec![ + "config:app:set", + "core", + "backgroundjobs_mode", + "--value", + "cron", + ], + None, + Vec::::default(), + ) + .await?; let domains = [ip_str.as_str(), "cloud", &cloud.id, host]; for (i, domain) in domains.iter().enumerate() {