Giter Site home page Giter Site logo

ansible-forever's Introduction

Forever

Ansible role to install Forever and and configure Upstart to ensure that the given Node.js scripts runs continuously.

Requirements

  • Node.js and npm
  • Upstart

Role Variables

  • forever_root: The full path to Forever working directory. Defaults to "/var/run/forever".
  • forever_user: The username of the user to run Forever managed process as. Defaults to "root".
  • forever_env: Environment variables for the Upstart jobs, as a hash. Defaults to {}.
  • forever_node_bin_dir: The full path to the directory containing the node and forever binaries. Defaults to "/usr/local/bin".
  • forever_node_path: Set the full path to the Node.js main node_modules directory. Defaults to "/usr/local/lib/node_modules".
  • forever_applications: A list of Node.JS application configurations, each configuration is a hash with the following properties:
    • name: The application name (must be a valid filename).
    • file: The application startup Javascript file path.
    • pid_file: Process ID file path. Defaults to /var/run/{{name}}.pid.
    • log_file: Log file path. Defaults to /var/log/{{name}}.log.
    • min_uptime: Minimum uptime, in milliseconds. Defaults to 5000.
    • spin_sleep_time: Spin sleep time, in milliseconds. Defaults to 2000.
    • enabled: Whether or not the application should be enabled. Defaults to true.
    • env: Environment variables for the Upstart Job, as a hash. Defaults to {}.
    • command: The command to use to run the application file. Defaults to node.
  • forever_start_on: The upstart event to start Forever managed processes at. Defaults to "startup".
  • forever_stop_on: The upstart event to stop Forever managed processes at. Defaults to "startup".

Example Playbook

- hosts: servers
  roles:
     - name: forever
       # Start forever process once Vagrant sync. folders are mounted.
       forever_start_on: vagrant-mounted
       # Set NOD_ENV environment for all Upstart managed processes.
       forever_env:
         NODE_ENV: production
       forever_applications:
       # A simple Node server, running on a fixed port.
       - name: foo-server
         file: "/home/node/foo/server.js"
       # A server requiring ES6 features (aka. Harmony), running on a configurable port.           
       - name koa-server
         file "/home/node/koaapp/server.js"
         command: node --harmony
         env:
           BIND_PORT: 8081

License

Apache v2

Author Information

ansible-forever's People

Contributors

dearlordylord avatar jpcolomer avatar pbuyle avatar vevmesteren avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.