Bläddra i källkod

Fix cron unexpectedly fails to start after being enabled #760 (#1309)

Mark Shust 2 månader sedan
förälder
incheckning
49d482b636
2 ändrade filer med 17 tillägg och 0 borttagningar
  1. 11 0
      compose/bin/cron
  2. 6 0
      compose/bin/start

+ 11 - 0
compose/bin/cron

@@ -1,5 +1,16 @@
 #!/usr/bin/env bash
 [ -z "$1" ] && echo "Please specify a service operation (start|stop|status|restart|reload|force-reload)" && exit
+
+if [ "$1" == "start" ]; then
+  # Create the .cron-enabled file when starting cron
+  bin/cli touch /var/www/html/var/.cron-enabled
+fi
+
+if [ "$1" == "stop" ]; then
+  # Remove the .cron-enabled file when stopping cron
+  bin/cli rm -f /var/www/html/var/.cron-enabled
+fi
+
 bin/root service cron "$@"
 bin/root touch /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status
 bin/root chown app:app /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status

+ 6 - 0
compose/bin/start

@@ -66,4 +66,10 @@ bin/docker-compose up -d --remove-orphans "$@"
 ## Then uncomment the below line (and leave uncommented) to start the agent automatically with bin/start:
 #bin/root /etc/init.d/blackfire-agent start
 
+# Check if cron was previously enabled and restart it if needed
+if bin/cli test -f /var/www/html/var/.cron-enabled; then
+  echo "Cron was previously enabled, restarting cron service..."
+  bin/cron start
+fi
+
 bin/cache-clean --watch