VRFS-214: created deb package config for jam-admin by cloning jam-web build setup

This commit is contained in:
Jonathan Kolyer 2013-01-16 06:02:09 -06:00
parent ff77da1cdd
commit 44c94f538b
16 changed files with 402 additions and 45 deletions

1
.rspec Normal file
View File

@ -0,0 +1 @@
--color

View File

@ -73,3 +73,12 @@ end
# To use debugger
# gem 'debugger'
group :development, :test do
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '0.5.5'
gem 'jasmine', '1.3.1'
gem 'pry'
gem 'execjs', '1.4.0'
gem 'therubyracer', '0.11.0beta8'
end

View File

@ -1,19 +1,3 @@
PATH
remote: ~/workspace/jam-db/target/ruby_package
specs:
jam_db (0.0.1)
pg_migrate (= 0.1.6)
PATH
remote: ~/workspace/jam-pb/target/ruby/jampb
specs:
jampb (0.0.1)
PATH
remote: ~/workspace/jam-ruby
specs:
jam_ruby (0.0.1)
GEM
remote: https://rubygems.org/
remote: https://jamjam:blueberryjam@www.jamkazam.com/gems/
@ -59,6 +43,7 @@ GEM
activesupport (3.2.9)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
amq-client (0.9.10)
amq-protocol (>= 0.9.4)
eventmachine
@ -83,7 +68,10 @@ GEM
builder (3.0.4)
cabin (0.4.4)
json
childprocess (0.3.6)
ffi (~> 1.0, >= 1.0.6)
clamp (0.5.0)
coderay (1.0.8)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@ -93,16 +81,18 @@ GEM
coffee-script-source (1.4.0)
country-select (1.1.1)
daemons (1.1.9)
devise (2.1.2)
devise (2.2.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (1.4.0)
multi_json (~> 1.0)
fastercsv (1.5.5)
ffi (1.3.1)
formtastic (2.2.1)
actionpack (>= 3.0)
fpm (0.4.6)
@ -111,6 +101,13 @@ GEM
cabin (~> 0.4.3)
clamp
json
guard (1.6.1)
listen (>= 0.6.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-rspec (0.5.5)
guard (>= 0.8.4)
has_scope (0.5.1)
hashr (0.0.22)
hike (1.2.1)
@ -118,6 +115,16 @@ GEM
inherited_resources (1.3.1)
has_scope (~> 0.5.0)
responders (~> 0.6)
jam_db (0.0.86)
pg_migrate (= 0.1.6)
jam_ruby (0.0.97)
jampb (0.0.3888)
jasmine (1.3.1)
jasmine-core (~> 1.3.1)
rack (~> 1.0)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
jasmine-core (1.3.1)
journey (1.0.4)
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
@ -127,9 +134,14 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.7.4)
libwebsocket (0.1.7.1)
addressable
websocket
listen (0.7.2)
little-plugger (1.1.3)
logging (1.7.2)
little-plugger (>= 1.1.3)
lumberjack (1.0.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@ -139,6 +151,7 @@ GEM
activerecord (~> 3.1)
activesupport (~> 3.1)
polyamorous (~> 0.5.0)
method_source (0.8.1)
mime-types (1.19)
multi_json (1.5.0)
orm_adapter (0.4.0)
@ -150,7 +163,11 @@ GEM
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.3)
rack (1.4.3)
pry (0.9.11.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.4.4)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
@ -176,24 +193,47 @@ GEM
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
ref (1.0.2)
responders (0.9.3)
railties (~> 3.1)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
ruby-protocol-buffers (1.2.2)
rubyzip (0.9.9)
sass (3.2.5)
sass-rails (3.2.5)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.27.2)
childprocess (>= 0.2.5)
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
sendgrid (1.1.0)
json
json
slop (3.4.3)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
therubyracer (0.11.0beta8)
ref
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
@ -220,6 +260,7 @@ GEM
uuidtools (2.1.2)
warden (1.2.1)
rack (>= 1.0)
websocket (1.0.6)
will_paginate (3.0.3)
PLATFORMS
@ -235,17 +276,23 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
country-select
eventmachine (= 1.0.0)
execjs (= 1.4.0)
fpm
jam_db!
jam_ruby!
jampb!
guard-rspec (= 0.5.5)
jam_db
jam_ruby
jampb
jasmine (= 1.3.1)
jquery-rails
meta_search (>= 1.1.0.pre)
pg_migrate
pry
rails (= 3.2.9)
rspec-rails (= 2.11.0)
ruby-protocol-buffers (= 1.2.2)
sass-rails (~> 3.2.3)
sendgrid (= 1.1.0)
therubyracer (= 0.11.0beta8)
thin
tire (= 0.5.1)
uglifier (>= 1.0.3)

View File

@ -1,6 +0,0 @@
module JamRuby
class JamSessionMembersController < ApplicationController
active_scaffold "JamRuby::JamSessionMember" do |conf|
end
end
end

View File

@ -1,6 +0,0 @@
module JamRuby
class JamSessionsController < ApplicationController
active_scaffold "JamRuby::JamSession" do |conf|
end
end
end

View File

@ -1,11 +0,0 @@
module JamRuby
class UsersController < ApplicationController
active_scaffold "JamRuby::User" do |conf|
conf.subform.columns = ["name", "email", "admin", "can_invite"]
conf.create.columns = [:name, :email, :admin, :password, :password_confirmation, :can_invite]
conf.update.columns = [:name, :email, :admin, :password, :password_confirmation, :can_invite]
end
end
end

68
build Executable file
View File

@ -0,0 +1,68 @@
#!/bin/bash
echo "updating dependencies"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# 'target' is the output directory
rm -rf $DIR/target
mkdir $DIR/target
mkdir $DIR/target/deb
# put all dependencies into vendor/bundle
rm -rf vendor/bundle
rm Gemfile.lock # if we don't want versions to float, pin it in the Gemfile, not count on Gemfile.lock
bundle install --path vendor/bundle
bundle update
if [ "$?" = "0" ]; then
echo "success: updated dependencies"
else
echo "could not update dependencies"
exit 1
fi
if [ -z $SKIP_TESTS ]; then
echo "running rspec tests"
bundle exec rspec
if [ "$?" = "0" ]; then
echo "success: ran rspec tests"
else
echo "running rspec tests failed."
exit 1
fi
fi
if [ -n "$PACKAGE" ]; then
if [ -z "$BUILD_NUMBER" ]; then
echo "BUILD NUMBER is not defined"
exit 1
fi
type -P dpkg-architecture > /dev/null
if [ "$?" = "0" ]; then
ARCH=`dpkg-architecture -qDEB_HOST_ARCH`
else
echo "WARN: unable to determine architecture."
ARCH=`all`
fi
set -e
# cache all gems local, and tell bundle to use local gems only
bundle install --path vendor/bundle --local
# prepare production acssets
rm -rf $DIR/public/assets
bundle exec rake assets:precompile RAILS_ENV=production
# create debian using fpm
bundle exec fpm -s dir -t deb -p target/deb/jam-admin_0.1.${BUILD_NUMBER}_${ARCH}.deb -n "jam-admin" -v "0.1.$BUILD_NUMBER" --prefix /var/lib/jam-admin --after-install $DIR/script/package/post-install.sh --before-install $DIR/script/package/pre-install.sh --before-remove $DIR/script/package/pre-uninstall.sh --after-remove $DIR/script/package/post-uninstall.sh Gemfile .bundle config Rakefile script config.ru lib public vendor app
fi
echo "build complete"

View File

@ -18,3 +18,12 @@ development:
password: postgres
timeout: 2000
encoding: unicode
production:
adapter: postgresql
database: jam
username: postgres
password: postgres
host: localhost
pool: 5
timeout: 5000

102
config/unicorn.rb Normal file
View File

@ -0,0 +1,102 @@
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
worker_processes 4
# Since Unicorn is never exposed to outside clients, it does not need to
# run on the standard HTTP port (80), there is no reason to start Unicorn
# as root unless it's from system init scripts.
# If running the master process as root and the workers as an unprivileged
# user, do this to switch euid/egid in the workers (also chowns logs):
user "jam-admin", "jam-admin"
# Help ensure your application will always spawn in the symlinked
# "current" directory that Capistrano sets up.
working_directory "/var/lib/jam-admin" # available in 0.94.0+
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/.sock", :backlog => 64
listen 3100, :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
# feel free to point this anywhere accessible on the filesystem
pid "/var/run/jam-admin.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path "/var/lib/jam-admin/log/unicorn.stderr.log"
stdout_path "/var/lib/jam-admin/log/unicorn.stdout.log"
# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
# Enable this flag to have unicorn test client connections by writing the
# beginning of the HTTP headers before calling the application. This
# prevents calling the application for connections that have disconnected
# while queued. This is only guaranteed to detect clients on the same
# host unicorn runs on, and unlikely to detect disconnects even on a
# fast LAN.
check_client_connection false
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# The following is only recommended for memory/DB-constrained
# installations. It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# # This allows a new master process to incrementally
# # phase out the old master process with SIGTTOU to avoid a
# # thundering herd (especially in the "preload_app false" case)
# # when doing a transparent upgrade. The last worker spawned
# # will then kill off the old master process with a SIGQUIT.
# old_pid = "#{server.config[:pid]}.oldbin"
# if old_pid != server.pid
# begin
# sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
# Process.kill(sig, File.read(old_pid).to_i)
# rescue Errno::ENOENT, Errno::ESRCH
# end
# end
#
# Throttle the master from forking too quickly by sleeping. Due
# to the implementation of standard Unix signal handlers, this
# helps (but does not completely) prevent identical, repeated signals
# from being lost when the receiving process is busy.
# sleep 1
end
after_fork do |server, worker|
# per-process listener ports for debugging/admin/migrations
# addr = "127.0.0.1:#{9293 + worker.nr}"
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
# if preload_app is true, then you may also want to check and
# restart any other shared sockets/descriptors such as Memcached,
# and Redis. TokyoCabinet file handles are safe to reuse
# between any number of forked children (assuming your kernel
# correctly implements pread()/pwrite() system calls)
end

View File

@ -0,0 +1,7 @@
description "jam-admin"
start on startup
start on runlevel [2345]
stop on runlevel [016]
exec start-stop-daemon --start --chdir /var/lib/jam-admin --exec /var/lib/jam-admin/script/package/upstart-run.sh

16
script/package/post-install.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
set -eu
NAME="jam-admin"
USER="$NAME"
GROUP="$NAME"
# copy upstart file
cp /var/lib/$NAME/script/package/$NAME.conf /etc/init/$NAME.conf
mkdir -p /var/lib/$NAME/log
mkdir -p /var/lib/$NAME/tmp
chown -R $USER:$GROUP /var/lib/$NAME

View File

@ -0,0 +1,27 @@
#!/bin/sh
NAME="jam-admin"
set -e
if [ "$1" = "remove" ]
then
set +e
# stop the process, if any is found. we don't want this failing to cause an error, though.
sudo stop $NAME
set -e
if [ -f /etc/init/$NAME.conf ]; then
rm /etc/init/$NAME.conf
fi
fi
if [ "$1" = "purge" ]
then
if [ -d /var/lib/$NAME ]; then
rm -rf /var/lib/$NAME
fi
userdel $NAME
fi

36
script/package/pre-install.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
set -eu
NAME="jam-admin"
HOME="/var/lib/$NAME"
USER="$NAME"
GROUP="$NAME"
# if NIS is used, then errors can occur but be non-fatal
if which ypwhich >/dev/null 2>&1 && ypwhich >/dev/null 2>&1
then
set +e
fi
if ! getent group "$GROUP" >/dev/null
then
addgroup --system "$GROUP" >/dev/null
fi
# creating user if it isn't already there
if ! getent passwd "$USER" >/dev/null
then
adduser \
--system \
--home $HOME \
--shell /bin/false \
--disabled-login \
--ingroup "$GROUP" \
--gecos "$USER" \
"$USER" >/dev/null
fi
# NISno longer a possible problem; stop ignoring errors
set -e

View File

20
script/package/upstart-run.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash -l
# default config values
PORT=3000
BUILD_NUMBER=1
CONFIG_FILE="/etc/jam-admin/upstart.conf"
if [ -e "$CONFIG_FILE" ]; then
. "$CONFIG_FILE"
fi
# I don't like doing this, but the next command (bundle exec) retouches/generates
# the gemfile. This unfortunately means the next debian update doesn't update this file.
# Ultimately this means an old Gemfile.lock is left behind for a new package,
# and bundle won't run because it thinks it has the wrong versions of gems
rm Gemfile.lock
BUILD_NUMBER=$BUILD_NUMBER exec bundle exec unicorn_rails -p $PORT -E production -c config/unicorn.rb # -D
#BUILD_NUMBER=$BUILD_NUMBER /usr/local/rbenv/shims/bundle exec rails s -p $PORT

38
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,38 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end