Sha256: b67848cb7b354dda6025aec4ef104351ae301fffc15de7b490c828545d30e2fd

Contents?: true

Size: 1.09 KB

Versions: 55

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' : ''
    ENV['PICKY_ENV'] = PICKY_ENVIRONMENT
    command = "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

55 entries across 55 versions & 1 rubygems

Version Path
picky-4.31.3 lib/tasks/server.rake
picky-4.31.2 lib/tasks/server.rake
picky-4.31.1 lib/tasks/server.rake
picky-4.31.0 lib/tasks/server.rake
picky-4.30.0 lib/tasks/server.rake
picky-4.29.0 lib/tasks/server.rake
picky-4.28.1 lib/tasks/server.rake
picky-4.27.1 lib/tasks/server.rake
picky-4.27.0 lib/tasks/server.rake
picky-4.26.2 lib/tasks/server.rake
picky-4.26.1 lib/tasks/server.rake
picky-4.26.0 lib/tasks/server.rake
picky-4.25.3 lib/tasks/server.rake
picky-4.25.2 lib/tasks/server.rake
picky-4.25.1 lib/tasks/server.rake
picky-4.25.0 lib/tasks/server.rake
picky-4.24.0 lib/tasks/server.rake
picky-4.23.2 lib/tasks/server.rake
picky-4.23.1 lib/tasks/server.rake
picky-4.23.0 lib/tasks/server.rake