The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
| #! /bin/bash | |
| ### BEGIN INIT INFO | |
| # Provides: unicorn | |
| # Required-Start: $local_fs $remote_fs $network $syslog | |
| # Required-Stop: $local_fs $remote_fs $network $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the unicorn web server | |
| # Description: starts unicorn |
| class ProtectedController << ApplicationController | |
| before_filter :force_user | |
| def index | |
| end | |
| private | |
| def force_user | |
| unless session[:user_id] | |
| session[:redirect_url] = request.fullpath | |
| redirect_to new_sessions_path |
| upstream myapp { | |
| server unix:///myapp/tmp/puma.sock; | |
| } | |
| server { | |
| listen 80; | |
| server_name myapp.com; | |
| # ~2 seconds is often enough for most folks to parse HTML/CSS and | |
| # retrieve needed images/icons/frames, connections are cheap in |
| /usr/sbin/update-rc.d -f unicorn defaults | |
| chmod +x /etc/init.d/unicorn | |
| /usr/sbin/update-rc.d -f unicorn remove |
| ((15, 'less_than', 30) == true) |
| #!/bin/sh | |
| set -u | |
| set -e | |
| # Example init script, this can be used with nginx, too, | |
| # since nginx and unicorn accept the same signals | |
| # Feel free to change any of the following variables for your app: | |
| APP_ROOT=/home/deploy/public_html/rm/current | |
| PID=$APP_ROOT/tmp/pids/unicorn.pid | |
| ENV=production |
Go to Heroku (https://www.heroku.com/) and create an account if you don’t have one
Install the heroku toolbelt from https://toolbelt.heroku.com/ or using Homebrew:
/> brew install heroku-toolbelt
Send you heroku account email to brian@binnacle.io
You’ll receive an email from heroku about being invited to test the alpha version of the binnacle add-on
Go to https://dashboard.heroku.com/apps to create a new app (+)
Clone https://github.com/binnacle-io/binnacle-rails-showcase: