Class: Dronejob::Command
- Inherits:
-
Thor
- Object
- Thor
- Dronejob::Command
- Defined in:
- lib/dronejob/command.rb
Instance Method Summary collapse
Instance Method Details
#archive ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dronejob/command.rb', line 39 def archive archive_dir = Workspace::Dir.new(File.join(Dir.pwd, "archive")) archive_dir.create Workspace::Dir.new(File.join(Dir.pwd, "tmp/jobs")).each_dir do |dir| dronejob_variables = dir.file("dronejob.yml").read_yaml next unless dronejob_variables[:dronejob_completed] == true Dronejob::Base.log("info", "Archiving #{dir.name}") archive_file = archive_dir.file("#{dir.name}.zip") if archive_file.exists? and !.force Dronejob::Base.log("error", "Error: Archive '#{archive_file}' already exists. Use --force to replace.") else archive_file.delete if archive_file.exists? dir.compress(archive_file) dir.delete end end end |
#continue ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/dronejob/command.rb', line 81 def continue job_dir = Workspace::Dir.new(File.join(Dir.pwd, "tmp/jobs")).dir(.job) dronejob_config = job_dir.file("dronejob.yml").read_yaml job_params = dronejob_config[:job_params] job_identifier = dronejob_config[:job_identifier] worker = Dronejob::Loader.workers[job_identifier] job_params["from"] = .from worker.perform_now(job_params) end |
#server ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/dronejob/command.rb', line 92 def server server = Server.new(Dronejob::Base.) begin server.start rescue Interrupt server.stop exit end end |
#unarchive ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dronejob/command.rb', line 63 def unarchive archives_dir = Workspace::Dir.new(File.join(Dir.pwd, "archive")) archive_file = archives_dir.file("#{.archive}.zip") Dronejob::Base.log("info", "Unarchiving '#{archive_file}'") target_dir = Workspace::Dir.new(File.join(Dir.pwd, "tmp/jobs")).dir(.archive) if !.force and target_dir.exists? Dronejob::Base.log("error", "Error: Job directory already exists") else target_dir.delete if target_dir.exists? archive_file.extract(target_dir) end end |