Sha256: 204fa13d8db2306e5c8d1c956d57f8c546bb98f81116003b355506eed6cdf353

Contents?: true

Size: 1.09 KB

Versions: 98

Compression:

Stored size: 1.09 KB

Contents

# Server tasks, like starting/stopping/restarting.
#
desc "Start the server."
task :start do
  Rake::Task[:'server:start'].invoke
end
desc "Stop the server."
task :stop do
  Rake::Task[:'server:stop'].invoke
end

namespace :server do

  # desc "Start the unicorns. (Wehee!)"
  #
  task :start => :framework do
    chdir_to_root
    daemonize = PICKY_ENVIRONMENT == 'production' ? '-D' : ''
    command = "export PICKY_ENV=#{PICKY_ENVIRONMENT}; unicorn -c unicorn.rb #{daemonize}".strip
    puts "Running \`#{command}\`."
    exec command
  end

  # desc "Stop the unicorns. (Blam!)"
  #
  task :stop => :framework do
    `kill -QUIT #{current_pid}` if current_pid
  end

  # desc "Restart the unicorns."
  task :restart do
    Rake::Task[:"server:stop"].invoke
    sleep 5
    Rake::Task[:"server:start"].invoke
  end

  def chdir_to_root
    Dir.chdir PICKY_ROOT
  end

  def current_pid
    pidfile = 'tmp/pids/unicorn.pid'
    pid = `cat #{File.join(PICKY_ROOT, pidfile)}`
    if pid.blank?
      puts
      puts "No server running (no #{pidfile} found)."
      puts
    else
      pid.chomp
    end
  end

end

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
picky-3.6.2 lib/tasks/server.rake
picky-3.6.1 lib/tasks/server.rake
picky-3.6.0 lib/tasks/server.rake
picky-3.5.4 lib/tasks/server.rake
picky-3.5.3 lib/tasks/server.rake
picky-3.5.2 lib/tasks/server.rake
picky-3.5.1 lib/tasks/server.rake
picky-3.5.0 lib/tasks/server.rake
picky-3.4.3 lib/tasks/server.rake
picky-3.4.2 lib/tasks/server.rake
picky-3.4.1 lib/tasks/server.rake
picky-3.4.0 lib/tasks/server.rake
picky-3.3.3 lib/tasks/server.rake
picky-3.3.2 lib/tasks/server.rake
picky-3.3.1 lib/tasks/server.rake
picky-3.3.0 lib/tasks/server.rake
picky-3.2.0 lib/tasks/server.rake
picky-3.1.13 lib/tasks/server.rake
picky-3.1.12 lib/tasks/server.rake
picky-3.1.11 lib/tasks/server.rake