capistrano-node-deploy-forever 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +73 -0
- data/LICENSE.txt +20 -0
- data/README.md +87 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/capistrano-node-deploy-forever.gemspec +65 -0
- data/lib/capistrano-node-deploy-forever.rb +1 -0
- data/lib/capistrano/node-deploy-forever.rb +102 -0
- data/test/helper.rb +18 -0
- metadata +159 -0
    
        data/.document
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,73 @@ | |
| 1 | 
            +
            GEM
         | 
| 2 | 
            +
              remote: http://rubygems.org/
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                activesupport (4.0.0)
         | 
| 5 | 
            +
                  i18n (~> 0.6, >= 0.6.4)
         | 
| 6 | 
            +
                  minitest (~> 4.2)
         | 
| 7 | 
            +
                  multi_json (~> 1.3)
         | 
| 8 | 
            +
                  thread_safe (~> 0.1)
         | 
| 9 | 
            +
                  tzinfo (~> 0.3.37)
         | 
| 10 | 
            +
                atomic (1.1.10)
         | 
| 11 | 
            +
                builder (3.2.2)
         | 
| 12 | 
            +
                faraday (0.8.7)
         | 
| 13 | 
            +
                  multipart-post (~> 1.1)
         | 
| 14 | 
            +
                git (1.2.5)
         | 
| 15 | 
            +
                github_api (0.8.1)
         | 
| 16 | 
            +
                  faraday (~> 0.8.1)
         | 
| 17 | 
            +
                  hashie (~> 1.2.0)
         | 
| 18 | 
            +
                  multi_json (~> 1.3)
         | 
| 19 | 
            +
                  nokogiri (~> 1.5.2)
         | 
| 20 | 
            +
                  oauth2
         | 
| 21 | 
            +
                hashie (1.2.0)
         | 
| 22 | 
            +
                highline (1.6.19)
         | 
| 23 | 
            +
                httpauth (0.2.0)
         | 
| 24 | 
            +
                i18n (0.6.4)
         | 
| 25 | 
            +
                jeweler (1.8.5)
         | 
| 26 | 
            +
                  builder
         | 
| 27 | 
            +
                  bundler (~> 1.0)
         | 
| 28 | 
            +
                  git (>= 1.2.5)
         | 
| 29 | 
            +
                  github_api (>= 0.8.1)
         | 
| 30 | 
            +
                  highline (>= 1.6.15)
         | 
| 31 | 
            +
                  nokogiri (= 1.5.10)
         | 
| 32 | 
            +
                  rake
         | 
| 33 | 
            +
                  rdoc
         | 
| 34 | 
            +
                json (1.8.0)
         | 
| 35 | 
            +
                jwt (0.1.6)
         | 
| 36 | 
            +
                  multi_json (>= 1.0)
         | 
| 37 | 
            +
                minitest (4.7.5)
         | 
| 38 | 
            +
                multi_json (1.3.7)
         | 
| 39 | 
            +
                multi_xml (0.5.4)
         | 
| 40 | 
            +
                multipart-post (1.2.0)
         | 
| 41 | 
            +
                nokogiri (1.5.10)
         | 
| 42 | 
            +
                oauth2 (0.9.2)
         | 
| 43 | 
            +
                  faraday (~> 0.8)
         | 
| 44 | 
            +
                  httpauth (~> 0.2)
         | 
| 45 | 
            +
                  jwt (~> 0.1.4)
         | 
| 46 | 
            +
                  multi_json (~> 1.0)
         | 
| 47 | 
            +
                  multi_xml (~> 0.5)
         | 
| 48 | 
            +
                  rack (~> 1.2)
         | 
| 49 | 
            +
                rack (1.5.2)
         | 
| 50 | 
            +
                railsless-deploy (1.1.2)
         | 
| 51 | 
            +
                rake (10.1.0)
         | 
| 52 | 
            +
                rdoc (3.12.2)
         | 
| 53 | 
            +
                  json (~> 1.4)
         | 
| 54 | 
            +
                shoulda (3.5.0)
         | 
| 55 | 
            +
                  shoulda-context (~> 1.0, >= 1.0.1)
         | 
| 56 | 
            +
                  shoulda-matchers (>= 1.4.1, < 3.0)
         | 
| 57 | 
            +
                shoulda-context (1.1.4)
         | 
| 58 | 
            +
                shoulda-matchers (2.2.0)
         | 
| 59 | 
            +
                  activesupport (>= 3.0.0)
         | 
| 60 | 
            +
                thread_safe (0.1.0)
         | 
| 61 | 
            +
                  atomic
         | 
| 62 | 
            +
                tzinfo (0.3.37)
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            PLATFORMS
         | 
| 65 | 
            +
              ruby
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            DEPENDENCIES
         | 
| 68 | 
            +
              bundler (~> 1.1)
         | 
| 69 | 
            +
              jeweler (~> 1.8.3)
         | 
| 70 | 
            +
              multi_json (~> 1.3.6)
         | 
| 71 | 
            +
              railsless-deploy
         | 
| 72 | 
            +
              rdoc (~> 3.12)
         | 
| 73 | 
            +
              shoulda
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2013 Brendan Keogh
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,87 @@ | |
| 1 | 
            +
            capistrano-node-deploy
         | 
| 2 | 
            +
            ======================
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Capistrano recipe for deploying node.js apps.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Features
         | 
| 7 | 
            +
            --------
         | 
| 8 | 
            +
            - Provides `cap deploy` functionality for your node app
         | 
| 9 | 
            +
            - Installs node packages (`npm install`) during deploys, using a shared folder for speed
         | 
| 10 | 
            +
            - Automatically creates upstart scripts for your node apps
         | 
| 11 | 
            +
            - Provides tasks for starting (`cap node:start`) and stopping (`cap node:stop`) your node app
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
            Usage
         | 
| 15 | 
            +
            -----
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            First install the gem:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                sudo gem install capistrano-node-deploy
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            or add it to your `Gemfile` if you have one:
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                gem "capistrano-node-deploy"
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            Now add the following to your `Capfile`
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                require "capistrano/node-deploy"
         | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| 30 | 
            +
            Full Capfile Example
         | 
| 31 | 
            +
            --------------------
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ```ruby
         | 
| 34 | 
            +
            require "capistrano/node-deploy"
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            set :application, "my-node-app-name"
         | 
| 37 | 
            +
            set :repository,  "git@github.com:/loopj/my-node-app-name"
         | 
| 38 | 
            +
            set :user, "deploy"
         | 
| 39 | 
            +
            set :scm, :git
         | 
| 40 | 
            +
            set :deploy_to, "/var/apps/my-app-folder"
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            role :app, "myserver.com"
         | 
| 43 | 
            +
            ```
         | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
            Overriding Default Settings
         | 
| 47 | 
            +
            ---------------------------
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            ```ruby
         | 
| 50 | 
            +
            # Set app command to run (defaults to index.js, or your `main` file from `package.json`)
         | 
| 51 | 
            +
            set :app_command, "my_server.coffee"
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            # Set additional environment variables for the app
         | 
| 54 | 
            +
            set :app_environment, "PORT=8080"
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            # Set node binary to run (defaults to /usr/bin/node)
         | 
| 57 | 
            +
            set :node_binary, "/usr/bin/coffee"
         | 
| 58 | 
            +
                
         | 
| 59 | 
            +
            # Set node environment (defaults to production)
         | 
| 60 | 
            +
            set :node_env, "staging"
         | 
| 61 | 
            +
                
         | 
| 62 | 
            +
            # Set the user to run node as (defaults to deploy)
         | 
| 63 | 
            +
            set :node_user, "james"
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            # Set the name of the upstart command (defaults to #{application}-#{node_env})
         | 
| 66 | 
            +
            set :upstart_job_name, "myserver"
         | 
| 67 | 
            +
            ```
         | 
| 68 | 
            +
             | 
| 69 | 
            +
             | 
| 70 | 
            +
            Contributing to capistrano-node-deploy
         | 
| 71 | 
            +
            --------------------------------------
         | 
| 72 | 
            +
             
         | 
| 73 | 
            +
            * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
         | 
| 74 | 
            +
            * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
         | 
| 75 | 
            +
            * Fork the project.
         | 
| 76 | 
            +
            * Start a feature/bugfix branch.
         | 
| 77 | 
            +
            * Commit and push until you are happy with your contribution.
         | 
| 78 | 
            +
            * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
         | 
| 79 | 
            +
            * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
         | 
| 80 | 
            +
             | 
| 81 | 
            +
             | 
| 82 | 
            +
            Copyright
         | 
| 83 | 
            +
            ---------
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            Copyright (c) 2012 James Smith. See LICENSE.txt for
         | 
| 86 | 
            +
            further details.
         | 
| 87 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
            require 'bundler'
         | 
| 5 | 
            +
            begin
         | 
| 6 | 
            +
              Bundler.setup(:default, :development)
         | 
| 7 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 8 | 
            +
              $stderr.puts e.message
         | 
| 9 | 
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 10 | 
            +
              exit e.status_code
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
            require 'rake'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            require 'jeweler'
         | 
| 15 | 
            +
            Jeweler::Tasks.new do |gem|
         | 
| 16 | 
            +
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         | 
| 17 | 
            +
              gem.name = "capistrano-node-deploy-forever"
         | 
| 18 | 
            +
              gem.homepage = "https://github.com/beekermememe/capistrano-node-deploy"
         | 
| 19 | 
            +
              gem.license = "MIT"
         | 
| 20 | 
            +
              gem.summary = %Q{Capistrano recipes for deploying node apps using forever module to manage the daemon}
         | 
| 21 | 
            +
              gem.description = %Q{Capistrano recipes for deploying node apps using forever module to manage the daemon}
         | 
| 22 | 
            +
              gem.email = "bkeogh123@gmail.com"
         | 
| 23 | 
            +
              gem.authors = ["Brendan Keogh"]
         | 
| 24 | 
            +
              # dependencies defined in Gemfile
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
            Jeweler::RubygemsDotOrgTasks.new
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            require 'rake/testtask'
         | 
| 29 | 
            +
            Rake::TestTask.new(:test) do |test|
         | 
| 30 | 
            +
              test.libs << 'lib' << 'test'
         | 
| 31 | 
            +
              test.pattern = 'test/**/test_*.rb'
         | 
| 32 | 
            +
              test.verbose = true
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            task :default => :test
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            require 'rdoc/task'
         | 
| 38 | 
            +
            Rake::RDocTask.new do |rdoc|
         | 
| 39 | 
            +
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 42 | 
            +
              rdoc.title = "capistrano-node-deploy-forever #{version}"
         | 
| 43 | 
            +
              rdoc.rdoc_files.include('README*')
         | 
| 44 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 45 | 
            +
            end
         | 
    
        data/VERSION
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            1.0.0
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            # Generated by jeweler
         | 
| 2 | 
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = "capistrano-node-deploy-forever"
         | 
| 8 | 
            +
              s.version = "1.0.0"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            +
              s.authors = ["Brendan Keogh"]
         | 
| 12 | 
            +
              s.date = "2013-09-05"
         | 
| 13 | 
            +
              s.description = "Capistrano recipes for deploying node apps using forever module to manage the daemon"
         | 
| 14 | 
            +
              s.email = "bkeogh123@gmail.com"
         | 
| 15 | 
            +
              s.extra_rdoc_files = [
         | 
| 16 | 
            +
                "LICENSE.txt",
         | 
| 17 | 
            +
                "README.md"
         | 
| 18 | 
            +
              ]
         | 
| 19 | 
            +
              s.files = [
         | 
| 20 | 
            +
                ".document",
         | 
| 21 | 
            +
                "Gemfile",
         | 
| 22 | 
            +
                "Gemfile.lock",
         | 
| 23 | 
            +
                "LICENSE.txt",
         | 
| 24 | 
            +
                "README.md",
         | 
| 25 | 
            +
                "Rakefile",
         | 
| 26 | 
            +
                "VERSION",
         | 
| 27 | 
            +
                "capistrano-node-deploy-forever.gemspec",
         | 
| 28 | 
            +
                "lib/capistrano-node-deploy-forever.rb",
         | 
| 29 | 
            +
                "lib/capistrano/node-deploy-forever.rb",
         | 
| 30 | 
            +
                "test/helper.rb"
         | 
| 31 | 
            +
              ]
         | 
| 32 | 
            +
              s.homepage = "https://github.com/beekermememe/capistrano-node-deploy"
         | 
| 33 | 
            +
              s.licenses = ["MIT"]
         | 
| 34 | 
            +
              s.require_paths = ["lib"]
         | 
| 35 | 
            +
              s.rubygems_version = "1.8.24"
         | 
| 36 | 
            +
              s.summary = "Capistrano recipes for deploying node apps using forever module to manage the daemon"
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              if s.respond_to? :specification_version then
         | 
| 39 | 
            +
                s.specification_version = 3
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 42 | 
            +
                  s.add_runtime_dependency(%q<railsless-deploy>, [">= 0"])
         | 
| 43 | 
            +
                  s.add_runtime_dependency(%q<multi_json>, ["~> 1.3.6"])
         | 
| 44 | 
            +
                  s.add_development_dependency(%q<shoulda>, [">= 0"])
         | 
| 45 | 
            +
                  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
         | 
| 46 | 
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.1"])
         | 
| 47 | 
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 48 | 
            +
                else
         | 
| 49 | 
            +
                  s.add_dependency(%q<railsless-deploy>, [">= 0"])
         | 
| 50 | 
            +
                  s.add_dependency(%q<multi_json>, ["~> 1.3.6"])
         | 
| 51 | 
            +
                  s.add_dependency(%q<shoulda>, [">= 0"])
         | 
| 52 | 
            +
                  s.add_dependency(%q<rdoc>, ["~> 3.12"])
         | 
| 53 | 
            +
                  s.add_dependency(%q<bundler>, ["~> 1.1"])
         | 
| 54 | 
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              else
         | 
| 57 | 
            +
                s.add_dependency(%q<railsless-deploy>, [">= 0"])
         | 
| 58 | 
            +
                s.add_dependency(%q<multi_json>, ["~> 1.3.6"])
         | 
| 59 | 
            +
                s.add_dependency(%q<shoulda>, [">= 0"])
         | 
| 60 | 
            +
                s.add_dependency(%q<rdoc>, ["~> 3.12"])
         | 
| 61 | 
            +
                s.add_dependency(%q<bundler>, ["~> 1.1"])
         | 
| 62 | 
            +
                s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
            end
         | 
| 65 | 
            +
             | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            # Nothing here, see lib/capistrano/node-deploy-forever.rb
         | 
| @@ -0,0 +1,102 @@ | |
| 1 | 
            +
            require "digest/md5"
         | 
| 2 | 
            +
            require "railsless-deploy"
         | 
| 3 | 
            +
            require "multi_json"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def remote_file_exists?(full_path)
         | 
| 6 | 
            +
              results = []
         | 
| 7 | 
            +
              invoke_command("if [ -e '#{full_path}' ]; then echo -n 'true'; fi") do |ch, stream, out|
         | 
| 8 | 
            +
                results << (out == 'true')
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
              results == [true]
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            def remote_file_content_same_as?(full_path, content)
         | 
| 14 | 
            +
              results = []
         | 
| 15 | 
            +
              invoke_command("md5sum #{full_path} | awk '{ print $1 }'") do |ch, stream, out|
         | 
| 16 | 
            +
                results << (out == Digest::MD5.hexdigest(content))
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
              results == [true]
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            def remote_file_differs?(full_path, content)
         | 
| 22 | 
            +
              exists = remote_file_exists?(full_path)
         | 
| 23 | 
            +
              !exists || exists && !remote_file_content_same_as?(full_path, content)
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            Capistrano::Configuration.instance(:must_exist).load do |configuration|
         | 
| 27 | 
            +
              default_run_options[:pty] = true
         | 
| 28 | 
            +
              before "deploy", "deploy:create_release_dir"
         | 
| 29 | 
            +
              before "deploy", "node:check_upstart_config"
         | 
| 30 | 
            +
              after "deploy:update", "node:install_packages", "node:restart"
         | 
| 31 | 
            +
              after "deploy:rollback", "node:restart"
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              package_json = MultiJson.load(File.open("package.json").read) rescue {}
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              set :application, package_json["name"] unless defined? application
         | 
| 36 | 
            +
              set :app_command, package_json["main"] || "index.js" unless defined? app_command
         | 
| 37 | 
            +
              set :app_environment, "" unless defined? app_environment
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              set :node_binary, "/usr/bin/node" unless defined? node_binary
         | 
| 40 | 
            +
              set :node_env, "production" unless defined? node_env
         | 
| 41 | 
            +
              set :node_user, "deploy" unless defined? node_user
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              set :stdout_log_path, lambda { "#{shared_path}/log/#{node_env}.out.log" }
         | 
| 44 | 
            +
              set :stderr_log_path, lambda { "#{shared_path}/log/#{node_env}.err.log" }
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              set :forever_start_script, lambda { "#{application}-#{node_env}" } unless defined? upstart_job_name
         | 
| 47 | 
            +
              _cset(:upstart_file_contents) {
         | 
| 48 | 
            +
            <<EOD
         | 
| 49 | 
            +
            #!upstart
         | 
| 50 | 
            +
            description "#{application} node app"
         | 
| 51 | 
            +
            author      "capistrano"
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            start on runlevel [2345]
         | 
| 54 | 
            +
            stop on shutdown
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            respawn
         | 
| 57 | 
            +
            respawn limit 99 5
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            script
         | 
| 60 | 
            +
                cd #{current_path} && exec sudo -u #{node_user} NODE_ENV=#{node_env} #{app_environment} #{node_binary} #{current_path}/#{app_command} 2>> #{stderr_log_path} 1>> #{stdout_log_path}
         | 
| 61 | 
            +
            end script
         | 
| 62 | 
            +
            EOD
         | 
| 63 | 
            +
              }
         | 
| 64 | 
            +
             | 
| 65 | 
            +
             | 
| 66 | 
            +
              namespace :node do
         | 
| 67 | 
            +
                desc "Check required packages and install if packages are not installed"
         | 
| 68 | 
            +
                task :install_packages do
         | 
| 69 | 
            +
                  run "mkdir -p #{shared_path}/node_modules"
         | 
| 70 | 
            +
                  run "cp #{release_path}/package.json #{shared_path}"
         | 
| 71 | 
            +
                  run "cp #{release_path}/npm-shrinkwrap.json #{shared_path}" if remote_file_exists?("#{release_path}/npm-shrinkwrap.json")
         | 
| 72 | 
            +
                  run "cd #{shared_path} && npm install #{(node_env != 'production') ? '--dev' : ''} --loglevel warn"
         | 
| 73 | 
            +
                  run "ln -s #{shared_path}/node_modules #{release_path}/node_modules"
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                desc "Start the node application"
         | 
| 77 | 
            +
                task :start do
         | 
| 78 | 
            +
                  "cd /srv/node/stats_d_proxy_server/current/"
         | 
| 79 | 
            +
                  "forever start #{forever_start_script}"
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                desc "Stop the node application"
         | 
| 83 | 
            +
                task :stop do
         | 
| 84 | 
            +
                  "cd /srv/node/stats_d_proxy_server/current/"
         | 
| 85 | 
            +
                  "forever stop #{forever_start_script}"
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                desc "Restart the node application"
         | 
| 89 | 
            +
                task :restart do
         | 
| 90 | 
            +
                  "cd /srv/node/stats_d_proxy_server/current/"
         | 
| 91 | 
            +
                  "forever restart #{forever_start_script}"
         | 
| 92 | 
            +
                end
         | 
| 93 | 
            +
              end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              namespace :deploy do
         | 
| 96 | 
            +
                task :create_release_dir, :except => {:no_release => true} do
         | 
| 97 | 
            +
                  mkdir_releases = "mkdir -p #{fetch :releases_path}"
         | 
| 98 | 
            +
                  mkdir_commands = ["log", "pids"].map {|dir| "mkdir -p #{shared_path}/#{dir}"}
         | 
| 99 | 
            +
                  run mkdir_commands.unshift(mkdir_releases).join(" && ")
         | 
| 100 | 
            +
                end
         | 
| 101 | 
            +
              end
         | 
| 102 | 
            +
            end
         | 
    
        data/test/helper.rb
    ADDED
    
    | @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'bundler'
         | 
| 3 | 
            +
            begin
         | 
| 4 | 
            +
              Bundler.setup(:default, :development)
         | 
| 5 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 6 | 
            +
              $stderr.puts e.message
         | 
| 7 | 
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 8 | 
            +
              exit e.status_code
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
            require 'test/unit'
         | 
| 11 | 
            +
            require 'shoulda'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 14 | 
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 15 | 
            +
            require 'capistrano-node-deploy-forever'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            class Test::Unit::TestCase
         | 
| 18 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,159 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: capistrano-node-deploy-forever
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Brendan Keogh
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-09-05 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: railsless-deploy
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '0'
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0'
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: multi_json
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ~>
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: 1.3.6
         | 
| 38 | 
            +
              type: :runtime
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ~>
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: 1.3.6
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: shoulda
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ! '>='
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '0'
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: rdoc
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ~>
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '3.12'
         | 
| 70 | 
            +
              type: :development
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ~>
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '3.12'
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: bundler
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 83 | 
            +
                - - ~>
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: '1.1'
         | 
| 86 | 
            +
              type: :development
         | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '1.1'
         | 
| 94 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 95 | 
            +
              name: jeweler
         | 
| 96 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 97 | 
            +
                none: false
         | 
| 98 | 
            +
                requirements:
         | 
| 99 | 
            +
                - - ~>
         | 
| 100 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                    version: 1.8.3
         | 
| 102 | 
            +
              type: :development
         | 
| 103 | 
            +
              prerelease: false
         | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                none: false
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - ~>
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: 1.8.3
         | 
| 110 | 
            +
            description: Capistrano recipes for deploying node apps using forever module to manage
         | 
| 111 | 
            +
              the daemon
         | 
| 112 | 
            +
            email: bkeogh123@gmail.com
         | 
| 113 | 
            +
            executables: []
         | 
| 114 | 
            +
            extensions: []
         | 
| 115 | 
            +
            extra_rdoc_files:
         | 
| 116 | 
            +
            - LICENSE.txt
         | 
| 117 | 
            +
            - README.md
         | 
| 118 | 
            +
            files:
         | 
| 119 | 
            +
            - .document
         | 
| 120 | 
            +
            - Gemfile
         | 
| 121 | 
            +
            - Gemfile.lock
         | 
| 122 | 
            +
            - LICENSE.txt
         | 
| 123 | 
            +
            - README.md
         | 
| 124 | 
            +
            - Rakefile
         | 
| 125 | 
            +
            - VERSION
         | 
| 126 | 
            +
            - capistrano-node-deploy-forever.gemspec
         | 
| 127 | 
            +
            - lib/capistrano-node-deploy-forever.rb
         | 
| 128 | 
            +
            - lib/capistrano/node-deploy-forever.rb
         | 
| 129 | 
            +
            - test/helper.rb
         | 
| 130 | 
            +
            homepage: https://github.com/beekermememe/capistrano-node-deploy
         | 
| 131 | 
            +
            licenses:
         | 
| 132 | 
            +
            - MIT
         | 
| 133 | 
            +
            post_install_message: 
         | 
| 134 | 
            +
            rdoc_options: []
         | 
| 135 | 
            +
            require_paths:
         | 
| 136 | 
            +
            - lib
         | 
| 137 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 138 | 
            +
              none: false
         | 
| 139 | 
            +
              requirements:
         | 
| 140 | 
            +
              - - ! '>='
         | 
| 141 | 
            +
                - !ruby/object:Gem::Version
         | 
| 142 | 
            +
                  version: '0'
         | 
| 143 | 
            +
                  segments:
         | 
| 144 | 
            +
                  - 0
         | 
| 145 | 
            +
                  hash: 1242977505471914095
         | 
| 146 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 147 | 
            +
              none: false
         | 
| 148 | 
            +
              requirements:
         | 
| 149 | 
            +
              - - ! '>='
         | 
| 150 | 
            +
                - !ruby/object:Gem::Version
         | 
| 151 | 
            +
                  version: '0'
         | 
| 152 | 
            +
            requirements: []
         | 
| 153 | 
            +
            rubyforge_project: 
         | 
| 154 | 
            +
            rubygems_version: 1.8.24
         | 
| 155 | 
            +
            signing_key: 
         | 
| 156 | 
            +
            specification_version: 3
         | 
| 157 | 
            +
            summary: Capistrano recipes for deploying node apps using forever module to manage
         | 
| 158 | 
            +
              the daemon
         | 
| 159 | 
            +
            test_files: []
         |