Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: chischaschos/scanty
base: ff6b30d166
...
head fork: chischaschos/scanty
compare: 50d292dfff
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 14 files changed
  • 0 commit comments
  • 1 contributor
View
2  .gitignore
@@ -5,3 +5,5 @@ blog.db
capybara*
coverage/
.env
+provisioning/vars/defaults.yml
+.vagrant*
View
28 Capfile
@@ -0,0 +1,28 @@
+# Load DSL and Setup Up Stages
+require 'capistrano/setup'
+
+# Includes default deployment tasks
+require 'capistrano/deploy'
+
+require 'capistrano/bundler'
+
+
+# Includes tasks from other gems included in your Gemfile
+#
+# For documentation on these, see for example:
+#
+# https://github.com/capistrano/rvm
+# https://github.com/capistrano/rbenv
+# https://github.com/capistrano/chruby
+# https://github.com/capistrano/bundler
+# https://github.com/capistrano/rails
+#
+# require 'capistrano/rvm'
+# require 'capistrano/rbenv'
+# require 'capistrano/chruby'
+# require 'capistrano/bundler'
+# require 'capistrano/rails/assets'
+# require 'capistrano/rails/migrations'
+
+# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
+Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
View
12 README.md
@@ -15,6 +15,8 @@ few changes:
[maruku](https://github.com/bhollis/maruku/). It is faster and has
better support for embedded html
- Uses [puma](https://github.com/puma/puma)
+- Contains provisioning support via [Ansible](http://www.ansible.com/home),
+[Vagrant](http://www.vagrantup.com/) and [Capistrano](http://capistranorb.com/)
Made some changes to the default code base in
order to remove empty spaces, fix test suite, upgrade used gems and
@@ -37,4 +39,12 @@ customize its configuration.
- Try to improve code so that codeclimate becomes happier [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/chischaschos/scanty)
## Provisioning
-Based on https://github.com/radar/ansible-rails-app
+
+- Based on https://github.com/radar/ansible-rails-app
+- Tips from http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/
+- Depending on https://github.com/dotless-de/vagrant-vbguest
+
+1. Copy provisioning/vars/defaults.yml.example to provisioning/vars/defaults.yml
+2. Set you deploy public key in [deploy_public_key](provisioning/vars/defaults.yml)
+3. Run ```vagrant up```
+4. Run ```cap staging deploy```
View
2  Vagrantfile
@@ -7,7 +7,7 @@ VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'precise64'
- #config.vm.network 'private_network', ip: '192.168.50.4'
+ config.vm.network 'private_network', ip: '192.168.50.4'
config.vm.provision 'ansible' do |ansible|
ansible.playbook = 'provisioning/site.yml'
View
44 config/deploy.rb
@@ -0,0 +1,44 @@
+set :application, 'emmanueldelgado.me'
+set :repo_url, 'git@github.com:chischaschos/scanty.git'
+set :deploy_to, '/data/site'
+set :log_level, :debug
+set :linked_files, %w{config/database.yml .env}
+set :linked_dirs, %w{tmp/sockets log config/puma}
+set :sockets_path, Pathname.new("#{fetch(:deploy_to)}/shared/tmp/sockets/")
+
+# These puma settings are only here because capistrano-puma is borked.
+# See issue #4.
+set :puma_roles, :app
+set :puma_socket, "unix://#{fetch(:sockets_path).join('puma_' + fetch(:application) + '.sock')}"
+set :pumactl_socket, "unix://#{fetch(:sockets_path).join('pumactl_' + fetch(:application) + '.sock')}"
+set :puma_state, fetch(:sockets_path).join('puma.state')
+set :puma_log, -> { shared_path.join("log/puma-#{fetch(:stage )}.log") }
+set :puma_flags, nil
+
+set :bundle_flags, '--deployment'
+
+namespace :deploy do
+ task :restart do
+ invoke 'puma:restart'
+ end
+end
+
+namespace :puma do
+ desc "Restart puma instance for this application"
+ task :restart do
+ on roles fetch(:puma_roles) do
+ within release_path do
+ execute :bundle, "exec pumactl -S #{fetch(:puma_state)} restart"
+ end
+ end
+ end
+
+ desc "Show status of puma for this application"
+ task :status do
+ on roles fetch(:puma_roles) do
+ within release_path do
+ execute :bundle, "exec pumactl -S #{fetch(:puma_state)} stats"
+ end
+ end
+ end
+end
View
39 config/deploy/production.rb
@@ -0,0 +1,39 @@
+# Simple Role Syntax
+# ==================
+# Supports bulk-adding hosts to roles, the primary
+# server in each group is considered to be the first
+# unless any hosts have the primary property set.
+# Don't declare `role :all`, it's a meta role
+role :app, %w{deploy@example.com}
+role :web, %w{deploy@example.com}
+role :db, %w{deploy@example.com}
+
+# Extended Server Syntax
+# ======================
+# This can be used to drop a more detailed server
+# definition into the server list. The second argument
+# something that quacks like a hash can be used to set
+# extended properties on the server.
+server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
+
+# you can set custom ssh options
+# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
+# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
+# set it globally
+# set :ssh_options, {
+# keys: %w(/home/rlisowski/.ssh/id_rsa),
+# forward_agent: false,
+# auth_methods: %w(password)
+# }
+# and/or per server
+# server 'example.com',
+# user: 'user_name',
+# roles: %w{web app},
+# ssh_options: {
+# user: 'user_name', # overrides user setting above
+# keys: %w(/home/user_name/.ssh/id_rsa),
+# forward_agent: false,
+# auth_methods: %w(publickey password)
+# # password: 'please use keys'
+# }
+# setting per server overrides global ssh_options
View
9 config/deploy/staging.rb
@@ -0,0 +1,9 @@
+server '127.0.0.1',
+ user: 'deploy',
+ roles: %w{app}
+
+set :ssh_options, {
+ forward_agent: true,
+ port: 2222,
+ #keys: %w(/some/place/private_key),
+}
View
2  provisioning/roles/database/tasks/postgresql.yml
@@ -23,7 +23,7 @@
command: service postgresql restart
- name: create the postgresql user for application
- postgresql_user: name=deploy
+ postgresql_user: name=deploy password=deploy
sudo_user: postgres
- name: create the postgresql database for application
View
5 provisioning/roles/webserver/tasks/deploy.yml
@@ -55,7 +55,7 @@
- name: Create deployment user
user: name=deploy comment="Application deployment user"
-#- authorized_key: user=deploy key='$FILE(~/.ssh/id_rsa.pub)'
+- authorized_key: user=deploy key="{{ lookup('file', deploy_public_key) }}"
- name: Create deployment directory
file: path={{deploy_directory}} owner=deploy group=deploy state=directory
@@ -75,5 +75,8 @@
- name: Install database.yml
template: src=database.yml.j2 dest={{deploy_directory}}/shared/config/database.yml force=yes mode=755 owner=deploy
+- name: Install .env
+ template: src=data_site_shared_config_env.j2 dest={{deploy_directory}}/shared/.env force=yes mode=755 owner=deploy
+
- name: Install Bundler
command: gem install bundler
View
5 provisioning/roles/webserver/templates/data_site_shared_config_env.j2
@@ -0,0 +1,5 @@
+DATABASE_URL=postgres://deploy:deploy@localhost:5432/app_emmanueldelgado.me
+BLOG_PASSWD=123
+COOKIE_KEY=123
+COOKIE_VALUE=123
+DISQUS_SHORTNAME=123
View
1  provisioning/roles/webserver/templates/etc_init_puma.j2
@@ -33,4 +33,5 @@ script
cd {{deploy_directory}}/current
logger -t puma "Starting server: $app"
exec bundle exec puma -C {{deploy_directory}}/current/config/puma/production.rb
+stdout_redirect "/data/site/shared/log/puma.stdout.log", "/data/site/shared/log/puma.stderr.log"
end script
View
2  provisioning/roles/webserver/templates/puma_production.j2
@@ -9,7 +9,7 @@ workers 2
# ActiveRecord::Base.establish_connection(ENV["DATABASE_URL"] || YAML.load_file("#{cwd}/config/database.yml")["production"])
# end
-bind 'unix://{{deploy_directory}}/shared/tmp/sockets/puma_spree.sock'
+bind 'unix://{{deploy_directory}}/shared/tmp/sockets/puma_emmanueldelgado.me.sock'
environment 'production'
pidfile "{{deploy_directory}}/shared/tmp/puma.pid"
state_path "{{deploy_directory}}/shared/tmp/sockets/puma.state"
View
1  provisioning/site.yml
@@ -1,6 +1,7 @@
---
- hosts: all
sudo: yes
+
vars_files:
- vars/defaults.yml
View
9 provisioning/vars/defaults.yml → provisioning/vars/defaults.yml.example
@@ -5,7 +5,10 @@ app_name: emmanueldelgado.me
## stolen from https://github.com/jgrowl/ansible-playbook-ruby-from-src
rubyTmpDir: /usr/local/src
-rubyUrl: http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
-rubyCompressedFile: ruby-2.1.0.tar.gz
-rubyName: ruby-2.1.0
+rubyUrl: http://cache.ruby-lang.org/pub/ruby/ruby-1.9.3-p545.tar.gz
+rubyCompressedFile: ruby-1.9.3-p545.tar.gz
+rubyName: ruby-1.9.3-p545
tmpRubyPath: "{{rubyTmpDir}}/{{rubyName}}"
+
+## deploy
+deploy_public_key: /your/deploy/public_key

No commit comments for this range

Something went wrong with that request. Please try again.