Sha256: 2e695a4f0e962c9e724a5fd4b1bf9ed497ef8b3c9dd54948c6004e6fdb2c24ab

Contents?: true

Size: 951 Bytes

Versions: 11

Compression:

Stored size: 951 Bytes

Contents

# TODO This file needs some love.
#
namespace :server do
  
  def chdir_to_root
    Dir.chdir PICKY_ROOT
  end
  
  def current_pid
    pid = `cat #{File.join(PICKY_ROOT, 'tmp/pids/unicorn.pid')}`
    pid.blank? ? nil : pid.chomp
  end
  
  desc "Start the unicorns. Weheee!"
  task :start => :framework do
    chdir_to_root
    # Rake::Task[:"solr:start"].invoke # TODO Move to better place.
    daemonize = PICKY_ENVIRONMENT == 'production' ? '-D' : ''
    command = "export PICKY_ENV=#{PICKY_ENVIRONMENT}; unicorn -c unicorn.ru #{daemonize}".strip
    puts "Running \`#{command}\`."
    exec command
  end
  
  desc "Stop the unicorns. Blam!"
  task :stop => :framework do
    `kill -QUIT #{current_pid}` if current_pid
    # Rake::Task[:"solr:stop"].invoke # TODO Move to better place.
  end
  
  desc "Restart the unicorns!"
  task :restart do
    Rake::Task[:"server:stop"].invoke
    sleep 5
    Rake::Task[:"server:start"].invoke
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
picky-0.3.0 lib/tasks/server.rake
picky-0.2.4 lib/tasks/server.rake
picky-0.2.3 lib/tasks/server.rake
picky-0.2.2 lib/tasks/server.rake
picky-0.2.1 lib/tasks/server.rake
picky-0.2.0 lib/tasks/server.rake
picky-0.1.0 lib/tasks/server.rake
picky-0.0.9 lib/tasks/server.rake
picky-0.0.8 lib/tasks/server.rake
picky-0.0.7 lib/tasks/server.rake
picky-0.0.6 lib/tasks/server.rake