ryanlelek.daemon-nodejs
Daemon - Node.js
Run a Node.js process as a Daemon using Upstart (switching to Systemd soon)
Requirements
Needed:
- Node.js (installed using the role: nodesource.node)
Recommended:
- Git (installed using the role: ryanlelek.packages)
Role Variables
- daemon_name: Name for the daemon, default is nodejs_daemon
- daemon_command: Command to run, default is npm start
- daemon_envvars: Environment variables for the process, default is an empty list []
Dependencies
- nodesource.node
Example Playbook
# Run as Root
- hosts: all
become: yes
roles:
- ryanlelek.packages
- nodesource.node
# Run as User
- hosts: all
roles:
# Clone a Node.js Git repository
- role: ryanlelek.git-repo
git_repo_name: raneto
git_repo_url: https://github.com/gilbitron/Raneto.git
git_repo_command: npm install
# Set up the Daemon
- role: ryanlelek.daemon-nodejs
daemon_name: raneto
daemon_command: npm start
daemon_envvars:
- { key: NODE_ENV, value: PRODUCTION }
- { key: PORT, value: 3000 }
License
MIT License
Author Information
Created by Ryan Lelek
Part of AnsibleTutorials.com