You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
707 B
30 lines
707 B
require_relative "spork"
|
|
require_relative "runner"
|
|
|
|
class MockManager
|
|
attr :path, :config, :error, :last_status, :last_pid, :prep_dir, :db
|
|
|
|
def initialize(path, config, cfg_counter_path, db)
|
|
@error = nil
|
|
unless File.exist? (path)
|
|
Dir.mkdir(path)
|
|
end
|
|
@path = path
|
|
@config = config
|
|
cntr = 0
|
|
@db = db
|
|
|
|
File.open(cfg_counter_path, "r+") do |f|
|
|
f.flock(File::LOCK_EX)
|
|
counter = f.gets.strip
|
|
i_counter = counter.to_i
|
|
i_counter = i_counter + 1
|
|
f.puts("#{i_counter}")
|
|
cnt = i_counter
|
|
end
|
|
tmp_name = (0...10).map { ("a".."z").to_a[rand(26)] }.join
|
|
@prep_dir = File.join(path, "#{cntr}_#{tmp_name}")
|
|
pp @prep_dir
|
|
end
|
|
end
|