Skip to content

Commit

Permalink
Fix for cron.service: Start request repeated too quickly. (#725)
Browse files Browse the repository at this point in the history
* Update cron-schedule.sh

restarts to often

* Create cron-restart.sh

only need to restart once.

* Update homestead.rb

restart cron daemon once to prevent 
homestead systemd[1]: cron.service: Start request repeated too quickly.

https://laracasts.com/discuss/channels/servers/homestead-create-schedule-fails
  • Loading branch information
Artistan authored and svpernova09 committed Nov 20, 2017
1 parent 2e0d769 commit cc9a737
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions scripts/cron-restart.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

service cron restart
2 changes: 0 additions & 2 deletions scripts/cron-schedule.sh
Expand Up @@ -10,5 +10,3 @@ SITE_PUBLIC_DIRECTORY=$2
cron="* * * * * vagrant /usr/bin/php $SITE_PUBLIC_DIRECTORY/../artisan schedule:run >> /dev/null 2>&1"

echo "$cron" > "/etc/cron.d/$SITE_DOMAIN"

service cron restart
7 changes: 7 additions & 0 deletions scripts/homestead.rb
Expand Up @@ -184,6 +184,7 @@ def Homestead.configure(config, settings)
end

if settings.include? 'sites'
has_cron = false
settings["sites"].each do |site|

# Create SSL certificate
Expand Down Expand Up @@ -220,6 +221,7 @@ def Homestead.configure(config, settings)
if (site["schedule"])
s.path = scriptDir + "/cron-schedule.sh"
s.args = [site["map"].tr('^A-Za-z0-9', ''), site["to"]]
has_cron = true
else
s.inline = "rm -f /etc/cron.d/$1"
s.args = [site["map"].tr('^A-Za-z0-9', '')]
Expand All @@ -233,6 +235,11 @@ def Homestead.configure(config, settings)
end
end
end
# Restart cron daemon
if has_cron
config.vm.provision "shell" do |s|
s.path = scriptDir + "/cron-restart.sh"
end
end

config.vm.provision "shell" do |s|
Expand Down

0 comments on commit cc9a737

Please sign in to comment.