Sha256: 7dd403ed12eeaeef5510ad6659396a2a90cbb3d666357ac269d2d0c6c843f386

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

#!/usr/bin/ruby -w
#
# backlog      Startup script for the backlog application
#
# chkconfig: 345 88 12
# description: Backlog

require 'rubygems'
require 'fileutils'

APPLICATION = 'backlog'

gem = Gem::searcher.find(APPLICATION)
  INSTALL_DIR = "/usr/lib/ruby/gems/1.8/gems/#{APPLICATION}-#{gem.version}"
else
  INSTALL_DIR = "/usr/local/backlog/current"
end

LOG_DIR = "#{INSTALL_DIR}/log"

# See how we were called.
case ARGV[0]
  when 'start':
        Dir.mkdir LOG_DIR unless File.exists? LOG_DIR
    `mongrel_rails start -p 3000 -e production -c #{INSTALL_DIR} -d -m #{INSTALL_DIR}/config/mime_types.yaml 1>#{LOG_DIR}/stdout.log 2>#{LOG_DIR}/stderr.log`
  when 'stop':
    `mongrel_rails stop -c #{INSTALL_DIR}`
  when 'restart':
    puts `mongrel_rails restart -c #{INSTALL_DIR}`
  when 'status'
    puts `ps -ef | grep backlog`
  when 'setup_linux'
    current_user = `whoami`
    users = `su - postgres -c "echo '\\du' | psql template1"`
    puts users
    unless users =~ /root/
      puts `su - postgres -c "createuser -dA #{current_user}"`
    end
    dbs = `su - postgres -c "echo '\\l' | psql template1"`
    puts dbs
    unless dbs =~ /#{APPLICATION}_production/
      puts `su - postgres -c "createdb #{APPLICATION}_production"`
    end
    Dir.chdir INSTALL_DIR
    puts `rake db:migrate RAILS_ENV=production`
    FileUtils.cp "#{INSTALL_DIR}/bin/#{APPLICATION}_init.d", "/etc/init.d/#{APPLICATION}"
  else
    puts "Usage: #$0 {start|stop|restart|status|setup}"
    exit 1
end

exit 0

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backlog-0.3.1 bin/backlog