Sha256: 96fcb8e739c38cd90bbc67e1a842277bf9c71b38a0ee05bcb18fd401b4d8a8ab
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
module Makesure class Cron # specify a file (or directory containing files) to load system specifications from def initialize(opts = {}) opts = { :cron_path => "/etc/cron.d/makesure.cron", :rvm => false }.merge(opts) Makesure.log "updating '#{opts[:cron_path]}'" cron_file = File.expand_path(opts[:cron_path]) crontab = build_crontab_output(opts) Makesure.debug "#{cron_file}:\n#{crontab}" File.open(cron_file, "w") do |f| f.write(crontab) end end def build_crontab_output(opts) chdir = Makesure.chdir || File.dirname(Makesure.makesurefile) crontab = "" crontab << "# Autogenerated by makesure: you probably don't want to edit this file\n\n" crontab << "# Cron environment\n" crontab << (Makesure.cron_env || "# customize this by setting Makesure.cron_env in your Makesurefile") crontab << "\n" Makesure.systems.each do |s| uid = s.uid || Makesure.uid crontab << "\n" crontab << "## Tasks for '#{s.name}'\n" crontab << "# Commands\n" s.cmds.each do |c| crontab << "#{c.cron}\t" crontab << "#{uid} " if uid crontab << "cd #{chdir} && " cmd = "makesure-runner run #{c.command.inspect}" crontab << if (opts[:rvm]) "/bin/bash -l -c '#{cmd}'" else cmd end crontab << "\n" end crontab << "# Verification\n" s.verifies.each do |v| crontab << "#{v.cron}\t" crontab << "#{uid} " if uid crontab << "cd #{chdir} && " cmd = "makesure-runner verify #{s.name} #{v.name}" crontab << if (opts[:rvm]) "/bin/bash -l -c '#{cmd}'" else cmd end crontab << "\n" end # TODO summarizes end crontab end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
makesure-0.0.6 | lib/makesure/cron.rb |