Code Monkey home page Code Monkey logo

capistrano-4ever's Introduction

capistrano-4ever

This gem provides some Capistrano3 tasks for deploying NodeJS servers using the npm package Forever to make sure that that application runs forever. The gem is named 'capistrano-4ever', as 'capistrano-forever' was taken (thus, perhaps, rendering this gem redundant). In any case, this gem namespaces under 'forever' instead of '4ever', and so the two gems are incompatible.

Available via RubyGems

Installation

Add this line to your application's Gemfile:

gem 'capistrano-4ever'

And then execute:

% bundle

Or install it yourself as:

% gem install capistrano-4ever

Usage

Require in Capfile:

require 'capistrano/forever'

Configuration options to be set in deploy.rb

:forever_env_variables : Any environmental variables you'd like, as a hash. I recommend setting NODE_ENV here.
:forever_path : Path to globally installed forever binary.
:forever_app : The application you're deploying.
:forever_target_path : The target path. Defaults to Capistrano's release_path. I recommend that you don't set this.
:forever_flags : Flags to pass to the forever binary as a string.

  • NB: Order is important here! Ape the order in the example below or play around, but don't be frustrated if something that seems like it should work doesn't. This is due to how the foreman binary parses options.

Configuration defaults

Configuration symbol Default
:forever_env_variables {}
:forever_path 'forever' (let env take care of pathing)
:forever_app 'main.js'
:forever_target_path Capistrano's release_path
:forever_flags '--append --uid <forever_app>'

Configuration recommendations

I recommend setting:
-l : So that you can have a shared logfile across deploys
--append : Append to logfiles and don't die when the logfile exists
--minUptime : If nothing else, keep NodeJS from complaing that you didn't set it.
--spinSleepTime : See above
--uid <string> : Set a custom string so that this gem will be able to stop previously-started instances.

Example

set :forever_env_variables, {'NODE_ENV' => "#{fetch(:npm_env)}"}
set :forever_path, '/usr/bin/forever'
set :forever_app, 'dog-sitting-calendar.js'
set :forever_target_path, '/var/www/dogsit'
set :forever_flags, [ "-l #{fetch :forever_target_path}/log/forever.log",
                      '--append',
                      '--minUptime 1000',
                      '--spinSleepTime 1000',
                      "--uid '#{fetch :forever_app}'" ].join(' ')

Custom tasks

% bundle exec cap <environment> forever:<task>
  • check : Check for forever binary on deploy target
    • Displays human-readable output; not for scripting
  • start : Start NodeJS server with forever
  • stop: Stop NodeJS server with forever
  • restart : Restart NodeJS server with forever
  • stop_all : Stop all NodeJS servers managed by forever on target server
  • restart_all : Restart all NodeJS servers managed by forever on target server

Contributing

  1. Fork it ( https://github.com/oversee-ffleming/capistrano-forever/fork )
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Added a neat feature!')
  4. Push to the branch (git push origin new-feature)
  5. Create a new Pull Request

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.