Code Monkey home page Code Monkey logo

inploy's Introduction

ABOUT:

Inploy was born as an option to setup and deploy Rails applications in an easier and smarter way.

It automatically executes common tasks like migrate the database, install gems, package the assets, clean the cache, notify Hoptoad, restart the server, etc. This means you will not have a big deploy script calld ‘recipe’ like with other tools, only a simple deploy script with a few lines.

It uses Git to version the deploys and to pull or push only the modifications in each one. This means you will not have a lot of folders in the server (only one) with duplicated code and that ech deploy will be very fast.

It is very flexible, meaning you can create templates specifing how specific tasks must behave. As today, there are templates for Locaweb, for Rails 3 using git pull and Rails 3 using git push.

It works by default with Passenger, but you can specify another servers like Mongrel, Thin and Unicorn.

You can execute Inploy from a remote machine or from the server machine, meaning anynone can go to the deployment path and with only one command update the code and execute all the tasks.

As Inploy is very flexible, now you can also use it to execute an installation shell script in a server from an URL.

INSTALLATION:

As a plugin:

script/plugin install git://github.com/dcrec1/inploy.git

As a gem:

sudo gem install inploy

Please remember that when used as a gem, Inploy should be available in the deploy servers.

Rails 2.3.x note

When using rails 2.3.x, you should include the follow line into you Rakefile:

##### Rakefile
load "tasks/inploy.rake"

USAGE

When using Inploy with Rake, there are five tasks:

  • inploy:remote:install from=url

- connects to a list of servers and executes the script from url

  • inploy:remote:setup

- connects to a list of servers
- clones a git repository
- executes rake inploy:local:setup

  • inploy:remote:update or inploy:up

- connects to a list of servers
- executes inploy:local:update

  • inploy:remote:install

- connects to a list of servers
- reads the content of url specified by from=url without downloading the file and executes it

  • inploy:local:setup

- creates directories db and tmp/pids
- copies config/.[example|sample|template] files to config/
- creates the database
- executes init.sh file case it exists
- inits and updates the git submodules
- installs gems
- migrates the database
- updates the crontab from Whenever if being used
- cleans the cache, default tmp/cache
- cleans cached assets in public/assets if Jammit is installed
- starts the Delayed Job worker if script/delayed_job exist
- parses less files if more:parse task exists
- parses compass files if config/initializers/compass.rb exists
- parses coffeescript files with Barista if barista:brew task exist
- package the assets if asset:packager:build_all task exists
- notifies Hoptoad about the deploy, specifing the revision, repository and environment
- notifies NewRelic RPM about the deploy
- restarts the server

  • inploy:local:update

- pulls the repository
- inits and updates the git submodules
- copies config/.[example|sample|template] files to config/
- installs gems
- migrates the database
- updates the crontab from Whenever if being used
- cleans the cache, default tmp/cache
- cleans cached assets in public/assets if Jammit is installed
- restarts the Delayed Job worker if script/delayed_job exists
- parses less files if more:parse task exists
- parses compass files if config/initializers/compass.rb exists
- parses coffeescript files with Barista if barista:brew task exist
- package the assets if asset:packager:build_all task exists
- notifies Hoptoad about the deploy, specifing the revision, repository and environment
- notifies NewRelic RPM about the deploy
- restarts the server

If you don’t want to execute Rake, there are a few shortcuts:

inploy => inploy update => rake inploy:remote:update
inploy setup => rake inploy:remote:setup
inploy install from=url => rake inploy:remote:install from=url

When using inploy as a command, it looks first for config/deploy.rb and then for deploy.rb .

CONFIGURATION

Create a config/deploy.rb file and configure it something like this:

application = "signal"
repository = 'git://github.com/dcrec1/signal.git'
hosts = ['hooters', 'geni']

# OPTIONALS

before_restarting_server do
  rake "important:task"
  run "important_command"
end

path = '/opt'                                # default /var/local/apps
user = 'dcrec1'                              # default deploy
ssh_opts = '-A'                              # default empty
branch = 'new_version'                       # default master
environment = 'staging'                      # default production
sudo = true                                  # default false
cache_dirs = ['public/cache', 'tmp/cache']   # default ['public/cache']
skip_steps = ['install_gems', 'clear_cache'] # default []
app_folder = 'project_folder'                # default empty
login_shell = true                           # default false
bundler_opts = '--binstubs'                  # default '--deployment --without development test cucumber'

The bundler_path option has been removed. To migrate your existing config/deploy.rb file simply replace bundler_path = '/path/to/gems' with bundler_opts = '--path /path/to/gems'

SKIP STEPS

You can skip some steps when running a Rake task, just add “skip_steps” into your rake command line or add “skip_steps” to your deploy.rb to always skip those steps.

Currently the steps available to skip are:

- copy_sample_files: skip copying config/.[example|sample|template] files to config/
- install_gems: skip rake gems:install
- migrate_database: skip rake db:migrate
- clear_cache: skip removing cache directories
- update_crontab: skip updating the crontab with Whenever

  • Usage (params are comma separated):
rake inploy:remote:update skip_steps=install_gems,migrate_database

HOOKS

Currently, the following three hooks are available:

- before_git (not called before initial git clone)
- after_git
- after_setup
- before_restarting_server
- after_restarting_server

To show a “down for maintenance” page during the deployment, use the before_git and after_restarting_server hooks.

If you need another hook, please fork the project and implement it. Or submit an issue, it’s very easy.

say

Use the say method to show messages issued by your hooks.

# Show a simple message
say 'restart custom daemons'

# Show a message (blank output lines are suppressed)
say 'revert local changes' do |output|
  output << `git checkout . 2>&1`
end

CONTRIBUTORS

Inploy is brought to you by:

  • Diego Carrion
  • Douglas Campos
  • Kristopher Murata
  • Vitor Pellegrino
  • Josh Owens
  • Felipe
  • trooster
  • Josef Pospíšil
  • BrunoGrasselli
  • Andy Shen
  • alekenji
  • Erik Dahlstrand
  • Carlos Brando
  • Thomas Ritz
  • Sven Schwyn

LICENSE:

(The MIT License)

Copyright © 2015

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
‘Software’), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

inploy's People

Contributors

adaoraul avatar alekenji avatar bbcoimbra avatar bradoc avatar brunoadacosta avatar brunograsselli avatar carlosbrando avatar danrabinowitz avatar dcrec1 avatar fgrehm avatar jtadeulopes avatar lucascaton avatar pellegrino avatar queso avatar thomasritz avatar tomfarm avatar trooster avatar vaskoz avatar youngbrioche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inploy's Issues

config/deploy.rb - config settings not assigned

deploy.rb like this:

application = "signal"
repository = 'git://github.com/dcrec1/signal.git'
hosts = ['hooters', 'geni']

... wouldn't take any effect.

While this:

@application = "signal"
@repository = 'git://github.com/dcrec1/signal.git'
@hosts = ['hooters', 'geni']

... does work.

Uninitialized constant Bundler when I run rake inploy:remote:update

I'm in a Rails 3 project, If I run rake inploy:remote:update I get this:

Inploy => ssh  [email protected] 'cd /home/blah/myapp && rake inploy:local:update RAILS_ENV=production environment=production'
[email protected]'s password: 
xxxxxxxxxxxx

uninitialized constant Bundler
/home/blah/myapp/Rakefile:4

I have to say that I don't have any problem with Bundler if I run the rake task locally or if I run the rails' server, only when I try to do it via ssh, I know this is not exactly an Inploy issue because if I run this manually:

ssh  [email protected] 'cd /home/blah/myapp && rake inploy:local:update RAILS_ENV=production environment=production'

it doesn't work either, it throws the same error, but I decided to post it here anyway because I haven't found information about this problem.

Thanks!

[Feature Req] Staging Push

It would be cool to have the ability to define a staging server as well as production and then be able to deploy to staging with "inploy staging". Which would look into the the deploy.rb for the staging server / path.

Just a thought, not sure if this would be out of scope for inploy, but would be nice to do with inploy vs capistrano.

git submodule fails when rails dir is not the repo root dir

Inploy => git submodule update --init
You need to run this command from the toplevel of the working tree.

My repo is something like:
/my_repo_root/my_www_app

I run rake:local:update from 'my_www_app', because that is where config/deploy.rb is.

Unable to install as plugin in rails 3

Since script/plugin is no longer there in Rails 3, I tried to run

rails plugin install git://github.com/dcrec1/inploy.git

on Ruby MRI 1.9.2. I get an error that ftools cannot be required. Because ftools has been deprecated in Ruby 1.9, I think line 1 of install.rb should instead use FileUtils.

Inploy runs faulty git command on server during rake inploy:remote:setup

After setting up inploy with the rails3_push template the following error was noted in the terminal

error: unknown switch `e'
usage: git clean [-d] [-f] [-n] [-q] [-x | -X] [--] ...

-q, --quiet           be quiet
-n, --dry-run         dry run
-f, --force           force
-d                    remove whole directories
-x                    remove ignored files, too
-X                    remove only ignored files

This seems to be in response to the command

git clean -f -d -e public/system

NoMethodError when trying to run "inploy"

Output I get when trying to run inploy from inside my project.

/Library/Ruby/Gems/1.8/gems/inploy-1.7.2/lib/inploy/dsl.rb:71:in `remote_run': undefined method `each' for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/inploy-1.7.2/lib/inploy/deploy.rb:57:in `remote_update'
from /Library/Ruby/Gems/1.8/gems/inploy-1.7.2/lib/inploy/cli.rb:7:in `execute'
from /Library/Ruby/Gems/1.8/gems/inploy-1.7.2/bin/inploy:7
from /usr/bin/inploy:19:in `load'
from /usr/bin/inploy:19

Don't know how to build task 'inploy:local:update'

When running rake inploy:remote:update on my machine or on my server, I get Don't know how to build task 'inploy:remote:update'

When running it like

inploy

I get an error on my server telling:
Don't know how to build task 'inploy:local:update'

Maybe I should load manually the inploy tasks from somewher?

config file problem: local_variables not being loaded on ruby 1.9.x

Hello,
I'm using ruby 1.9.1-p376 and have tried this with 1.9.2

The project is configured fine, but when I execute

victorhg$ inploy setup
/Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/dsl.rb:48:in `remote_run': undefined method `each' for nil:NilClass (NoMethodError)
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/deploy.rb:48:in `remote_setup'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/cli.rb:9:in `execute'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/bin/inploy:7:in `<top (required)>'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/bin/inploy:19:in `load'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/bin/inploy:19:in `<main>'

Here's my config/deploy.rb file:

template = :rails3
application = "myProject"
repository = '[email protected]:user/project.git'
hosts = ['server']

path = '/var/www/'
user = 'rails'

Explaining the problem:

Well, because of the change on how eval method handles local variables, we cannot have something like this on ruby 1.9:

eval "variable = 1"
print variable

The way inploy handles the configuration parameters is not working (at least for me). Here is the problem in the code:

inploy/deploy.rb:27

def configure
    if file = configuration_file
      deploy = self
      eval file.read
      local_variables.each do |variable
        send "#{variable}=", eval(variable) rescue nil
      end
    end
  end

When executing eval file.read the variables are not created as local variables, but only as local variables inside the eval scope. To solve this, I had to change the config/deploy file to created instance variables:

@template = :rails3
@application = "myProject"
@repository = '[email protected]:user/project.git'
@hosts = ['server']

@path = '/var/www/'
@user = 'rails'

Maybe there's a better way to make it work... or I would be really glad to hear that it's just some stupid mistake I did....

thank you...

RVM error

When I build the application I found this error:

sh: rvm: not found

The RVM is already configured for some user that start the signal application

inploy:remote:setup constructs faulty command

Running inploy:remote:setup constructs a faulty shell command when a branch is set and login_shell = true:

Inploy => ssh -A [email protected] "bash -l -c 'cd /var/www && git clone --depth 1 git://github.com/innoq/iqvoc.git iqvoc_inploy && cd iqvoc_inploy && $(git branch | grep -vq inploy) && git checkout -f -b inploy origin/inploy && bundle install --path ~/.bundle --without development test cucumber && rake inploy:local:setup RAILS_ENV=production environment=production'"
bash: -c: Line 0: Syntax error at unexpected word `&&'

The problem seems to be that $(git branch | grep -vq inploy) returns nothing and the command therefore contains two && after each other.

What's $(git branch | grep -vq inploy) doing by the way?

Attributes in deploy.rb

Hi my argentine friend,

Inploy failed to read de values in deploy.rb file when I used de syntax deploy.application = "app" instead of application = "app".

I used the file example in the READ of inploy github source page as base to my own deploy.rb.
It's working with "deploy." prefix, but I don't know if it's a my fault or inploy a issue.

Regards.

Inploy binary doesn't work with custom templates

I'm in a rails 3 project and I added a lib/inploy/template/my_template.rb file, if I run the rake tasks it works, but if I try to fire the "inploy update" command it says:

deploy.rb:36:in `configure_from'
...
no such file to load -- inploy/templates/my_template.rb (LoadError)

Is this a not yet implemented feature, a bug or I'm doing something wrong? where should I place my custom templates and servers?

Execute barista:brew if the task is available

As you might know, there's a language called CoffeScript that compiles into javascript the same way SASS compiles to CSS.

Barista allows you to compile all your coffeescripts into javascripts with the task barista:brew. It would be nice to automatically execute it when using inploy.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.