class Photish::Command::Generate

Public Instance Methods

run() click to toggle source
# File lib/photish/command/generate.rb, line 4
def run
  log.debug "Generating with #{workers} workers and #{threads} threads"

  master_db_file_clear if force_regeneration?
  spawn_all_workers
  load_all_plugins
  wait_for_workers_to_complete
  concat_worker_db_files
  perform_serial_generation

  log.debug "Generation completed successfully"
end

Private Instance Methods

cache_repository() click to toggle source
# File lib/photish/command/generate.rb, line 71
def cache_repository
  Cache::Repository.new(output_dir, workers)
end
collection() click to toggle source
# File lib/photish/command/generate.rb, line 61
def collection
  @collection ||= Gallery::Collection.new(config)
end
force_regeneration?() click to toggle source
# File lib/photish/command/generate.rb, line 30
def force_regeneration?
  force == true
end
one_worker?() click to toggle source
# File lib/photish/command/generate.rb, line 48
def one_worker?
  workers == 1
end
perform_serial_generation() click to toggle source
# File lib/photish/command/generate.rb, line 56
def perform_serial_generation
  Render::Site.new(config)
              .all_for(collection)
end
single_worker() click to toggle source
# File lib/photish/command/generate.rb, line 52
def single_worker
  Worker.new(runtime_config.merge(worker_index: 1)).execute
end
spawn_all_workers() click to toggle source
# File lib/photish/command/generate.rb, line 34
def spawn_all_workers
  return single_worker if one_worker?
  @spawned_processes ||= (1..workers).map do |index|
    Process.spawn(ENV, worker_command(index))
  end
end
wait_for_workers_to_complete() click to toggle source
# File lib/photish/command/generate.rb, line 41
def wait_for_workers_to_complete
  return if one_worker?
  @spawned_processes.map do |pid|
    Process.waitpid(pid)
  end
end
worker_command(worker_index) click to toggle source
# File lib/photish/command/generate.rb, line 65
def worker_command(worker_index)
  [photish_executable,
   'worker',
   "--worker_index=#{worker_index}"].join(' ')
end