diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index dc90e5a..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 60 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security -# Label to use when marking an issue as stale -staleLabel: wontfix -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a02cca6..0000000 --- a/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -generated-CHANGES.md -test/sandbox -foreman-*.tgz -coverage/ -checkstyle.xml -tests.tap -.travis.yml -appveyor.yml diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index 3c3629e..0000000 --- a/.jshintignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index cb6660b..0000000 --- a/.jshintrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "node": true, - "esnext": true, - "bitwise": true, - "curly": true, - "immed": true, - "newcap": true, - "noarg": true, - "undef": true, - "unused": "vars", - "indent": 2 -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0650dbd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - "10" - - "8" - - "6" diff --git a/CHANGES.md b/CHANGES.md deleted file mode 100644 index e8deddc..0000000 --- a/CHANGES.md +++ /dev/null @@ -1,416 +0,0 @@ -2018-06-28, Version 3.0.1 -========================= - - * remove unnecessary use of regex (Ryan Graham) - - * Fixed typo on forward proxy (Cemal Eker) - - * Fixed typo (Leopold Bradley) - - * don't log warning if env file doesn't exist (Ryan Graham) - - -2018-05-21, Version 3.0.0 -========================= - - * Update outdated dependencies to latest (Miroslav Bajtoš) - - * Fix error "Unknown signal: null" (Kaspar Schiess) - - * Update supported Node.js versions (Miroslav Bajtoš) - - -2016-08-25, Version 2.0.0 -========================= - - * Update URLs in CONTRIBUTING.md (#123) (Ryan Graham) - - * update copyright statements (Ryan Graham) - - * replace mu2 with mustache (Ryan Graham) - - * enable node v6 on CI (Ryan Graham) - - -2016-04-30, Version 2.0.0-1 -=========================== - - * output environment varialbes in predicatable order (Ryan Graham) - - * Allow loading multiple ENV files. (Joe Esposito) - - * add --raw option to suppress log decorations (Andrew Herrington) - - * Changed handler name to error instead of proxyError (Nazar Hussain) - - * improve error messages when loading a procfile (toastynerd) - - * fix exported systemd unit dependencies (Guten Ye) - - * test: refactor tests to use ephemeral ports (Ryan Graham) - - * clean up CLI argument handling (Ryan Graham) - - * deps: upgrade commander (Ryan Graham) - - * fix padding of keys (Jeff Dickey) - - * fix 'nf' command name (Jeff Dickey) - - * disable trimming by default (Jeff Dickey) - - * reorderd colors (Jeff Dickey) - - * disable black/white colors (Jeff Dickey) - - * display exit code (Jeff Dickey) - - * test: use OS-specific env expansion (Ryan Graham) - - * test: improve assertion message (Ryan Graham) - - * disable node 6.x in Travis and Appveyor (Ryan Graham) - - * update Travis config and add Appveyor (Ryan Graham) - - * Remove note about dropping privileges (#108) (Ari Pollak) - - * fix jshint issues (Jeff Dickey) - - * jshint all local js files (Jeff Dickey) - - * added jshintignore (Jeff Dickey) - - * Add '' argument to sed -i to fix mac os tests (Ransom Briggs) - - * Small typo fix in README (Simon Taranto) - - -2015-11-18, Version 2.0.0-0 -=========================== - - * Dont' drop sudo (Vasiliy Yorkin) - - * Cleanup: No need to duplicate the color keys, can use Object.keys() to ext from colors object (Sathish Kumar) - - * Adds support for SSL proxy (Jeff Kolesky) - - * update package scripts to be more portable (Ryan Graham) - - * Fix README to reflect Proxy SwitchSharp is no longer mantained (Leo Gallucci) - - * fix forward proxy `http-proxy` usage (Victor Kotseruba) - - * fix spawning multiple proxies (Victor Kotseruba) - - -2015-06-09, Version 1.4.1 -========================= - - * package: don't include tests and fixtures (Ryan Graham) - - * update `http-proxy` (Victor Kotseruba) - - -2015-06-03, Version 1.4.0 -========================= - - * Lint in travis (jigsaw) - - * fix iojs version (jigsaw) - - * support node 0.12.x and iojs 1.6.x (jigsaw) - - * refactor lib/requirements (jigsaw) - - * refactor lib/proxy (jigsaw) - - * refactor lib/procfile (jigsaw) - - * refactor lib/proc (jigsaw) - - * refactor lib/forward (jigsaw) - - * refactor lib/exporters (jigsaw) - - * refactor lib/envs (jigsaw) - - * refactor console (jigsaw) - - * refactor lib/colors.js (jigsaw) - - * refactor forward.js (jigsaw) - - * refactor proxy.js and allow snake case (jigsaw) - - * refactor nf.js for jshint (jigsaw) - - * add jshint configure file (jigsaw) - - -2015-01-23, Version 1.3.0 -========================= - - * Preserve indentation, but trim trailing whitespace (Ryan Graham) - - * style: tabs to 2 spaces, clean up indentation only (Ryan Graham) - - -2015-01-12, Version 1.2.1 -========================= - - * Fix bad CLA URL in CONTRIBUTING.md (Ryan Graham) - - -2014-12-26, Version 1.2.0 -========================= - - * fix: honour PORT if set in .env file (Ryan Graham) - - * cli: simplify version loading (Ryan Graham) - - -2014-11-04, Version 1.1.0 -========================= - - * Propagate signals on exit (Ryan Graham) - - * Fix proxy errors on Windows (Ryan Graham) - - * Exit with non-zero on fatal error (Ryan Graham) - - * Adds a run command for running one-off processes (Jeff Jewiss) - - * Add contribution guidelines (Ryan Graham) - - -2014-09-29, Version 1.0.0 -========================= - - * Don't delete files (Ryan Graham) - - * [api] SMF export (for Solaris, Illumos, SmartOS) (Charles Phillips) - - -2014-08-15, Version 0.4.2 -========================= - - * Remove quotes from spawn on Windows (Ryan Graham) - - -2014-08-11, Version 0.4.1 -========================= - - * Regen CHANGES.md with updated script (Ryan Graham) - - * Use spawn for worker processes (Ryan Graham) - - * Update README so CLI's name, `nf`, is prominent (Sam Roberts) - - -2014-07-08, Version 0.4.0 -========================= - - * Allow overriding supervisord templates (Ryan Graham) - - * Update supervisord export instructions (Ryan Graham) - - * Fix the tests (Bret Little) - - * Add the ability to comment out tasks in a Procfile satisfying request #42 (Bret Little) - - * Fix inconsistent indentation style (Sam Roberts) - - * Remove package reference to non-existent index.js (Sam Roberts) - - * test: Update to test --cwd option (Ryan Graham) - - * export: Let --cwd accept absolute or relative path (Ryan Graham) - - * Add informations on supervisord export to README.md (Paul d'Hubert) - - * Allow cwd to be passed on CLI. (Paul d'Hubert) - - * Add --template option to export command (Ryan Graham) - - * Ignore ANSI escapes when doing line trimming (Ryan Graham) - - * Expand tabs to spaces (Paul d'Hubert) - - * Add test files for supervisord templates. (Paul d'Hubert) - - * Do not set a default cwd to '.' (Paul d'Hubert) - - * Fix an error when escaping numbers.. (Paul d'Hubert) - - * Escape supervisord envs values (Paul d'Hubert) - - * Correctly export supervisord group file (Paul d'Hubert) - - * Scope the 'i' variable in export's foreman_app_n loop (Paul d'Hubert) - - * Add 'n' to writeout.foreman's conf (Paul d'Hubert) - - * Add supervisord exporter (Paul d'Hubert) - - -2014-04-10, Version 0.3.0 -========================= - - * Handle env values with = in them (Ryan Graham) - - * Add new FOREMAN_WORKER_NAME automatic variable (Ryan Graham) - - * export: Improve comments in Upstart-single jobs (Ryan Graham) - - * export: Don't export PATH env var to subjobs (Ryan Graham) - - * env: Don't override PATH if set in .env (Ryan Graham) - - * export: Quote env var values in Upstart jobs (Ryan Graham) - - * upstart-single: Add coredump limits (Ryan Graham) - - * Fixed typo (Brian Gonzalez) - - -2014-03-28, Version 0.2.1 -========================= - - * proxy: Fix regression caused by http-proxy upgrade (Ryan Graham) - - -2014-03-28, Version 0.2.0 -========================= - - * Release v0.2.0 (Ryan Graham) - - * Ignore some CI files (Ryan Graham) - - * test: Some useful example files (Ryan Graham) - - * Disable colours if stdout is not a TTY (Ryan Graham) - - * procfile: Use real shell expansion for commands (Evan Owen) - - * test: Make PATH CI portable (Ryan Graham) - - * Add Travis-CI (Ryan Graham) - - * test: Use sed as fallback because sed may === gsed (Ryan Graham) - - * test: Improve test portability (Ryan Graham) - - * export: Use runlevels in Upstart jobs (Ryan Graham) - - * Version dependencies (Ryan Graham) - - -2014-03-27, Version 0.1.2 -========================= - - * Ignore npm packed tarballs (Ryan Graham) - - -2014-03-27, Version 0.1.1 -========================= - - * env: Ignore quoted #'s (Ryan Graham) - - * test: Failing test for # handling in .env (Ryan Graham) - - -2014-03-27, Version 0.1.0 -========================= - - * git: Ignore test/sandbox (Ryan Graham) - - * export: Don't auto-set PORT for upstart-single (Ryan Graham) - - * export: Use system logger for upstart-single (Ryan Graham) - - * export: Initial support for flattend upstart layout (Ryan Graham) - - * test: use strict PATH for tests (Ryan Graham) - - * test: Basic tests for current exporters (Ryan Graham) - - * refactor: Rename lib/upstart.js to be more accurate (Ryan Graham) - - * fix: regression from colors replacement (Ryan Graham) - - * test: Add basic tests for console logger (Ryan Graham) - - * console: Parameterize console for better testing (Ryan Graham) - - * src: replace dependency on colors module (Ryan Graham) - - * src: refactor .env parsing/loading (Ryan Graham) - - * test: Initial tests for .env parsing (Ryan Graham) - - * doc: Add CHANGES.md (Ryan Graham) - - -2014-03-18, Version 0.0.27 -========================== - - * fix: Allow - in app-name in Procfile (Ryan Graham) - - -2014-02-06, Version 0.0.26 -========================== - - * Bump for license and home change (Ryan Graham) - - * Update imaage URLs in README (Ryan Graham) - - * Change to MIT license (Ryan Graham) - - * Update owner and URLs (Ryan Graham) - - -2013-02-13, Version 0.0.25 -========================== - - * Version Bump (Jacob Groundwater) - - * Warn on Unmatched Variable Substitutions in Procfile (Jacob Groundwater) - - * Support both $var and ${var} style variables (Larz Conwell) - - * Procfile can use environment variables from process.env, and any defined in the loaded env file. variables defined in a .env file take precendence over process.env vars. (Larz Conwell) - - -2013-02-01, Version 0.0.24 -========================== - - * Version Bump (Jacob Groundwater) - - * Add Forward Proxy Section to README (Jacob Groundwater) - - * Rename Reverse Proxy Titles in README (Jacob Groundwater) - - * Handles Windows Procfiles with CRLF (Ethan J. Brown) - - -2013-01-23, Version 0.0.23 -========================== - - * Version Bump (Jacob Groundwater) - - * Fix My Foolishness (Jacob Groundwater) - - -2013-01-23, Version 0.0.22 -========================== - - * Version Bump (Jacob Groundwater) - - * Not being so precautious with quot marks (John Wright) - - -2013-01-22, Version 0.0.21 -========================== - - * First release! diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 128e8e9..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,85 +0,0 @@ -### Contributing ### - -Thank you for your interest in `foreman`, an open source project -administered by StrongLoop. - -Contributing to `foreman` is easy. In a few simple steps: - - * Ensure that your effort is aligned with the project's roadmap by - talking to the maintainers, especially if you are going to spend a - lot of time on it. - - * Make something better or fix a bug. - - * Adhere to code style outlined in the [Google C++ Style Guide][] and - [Google Javascript Style Guide][]. - - * Sign-off your commits to agree to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/) - - * Submit a pull request through Github. - - -### Sign Your Commits ### - -A `Signed-off-by` line added to your commits indicates that you are -adhering to the DCO: - -``` -This is my commit message - -Signed-off-by: Random J Developer -``` - -You can have `git` automatically add this line to your commits for you -with the `-s` flag: - -``` -$ git commit -s -m 'This is my commit message' -``` - -#### Developer Certificate of Origin #### - -This text is also available at https://developercertificate.org/ - -``` -Developer Certificate of Origin -Version 1.1 - -Copyright (C) 2004, 2006 The Linux Foundation and its contributors. -1 Letterman Drive -Suite D4700 -San Francisco, CA, 94129 - -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. - - -Developer's Certificate of Origin 1.1 - -By making a contribution to this project, I certify that: - -(a) The contribution was created in whole or in part by me and I - have the right to submit it under the open source license - indicated in the file; or - -(b) The contribution is based upon previous work that, to the best - of my knowledge, is covered under an appropriate open source - license and I have the right under that license to submit that - work with modifications, whether created in whole or in part - by me, under the same open source license (unless I am - permitted to submit under a different license), as indicated - in the file; or - -(c) The contribution was provided directly to me by some other - person who certified (a), (b) or (c) and I have not modified - it. - -(d) I understand and agree that this project and the contribution - are public and that a record of the contribution (including all - personal information I submit with it, including my sign-off) is - maintained indefinitely and may be redistributed consistent with - this project or the open source license(s) involved. -``` - -[Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html -[Google Javascript Style Guide]: https://google.github.io/styleguide/javascriptguide.xml diff --git a/LICENSE b/LICENSE deleted file mode 100644 index db5e0c3..0000000 --- a/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) IBM Corp. 2012,2016. All Rights Reserved. -Node module: foreman -This project is licensed under the MIT License, full text below. - --------- - -MIT license - -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. diff --git a/README.md b/README.md deleted file mode 100644 index e1103dd..0000000 --- a/README.md +++ /dev/null @@ -1,298 +0,0 @@ -# Node Foreman [![Build Status](https://travis-ci.org/strongloop/node-foreman.svg)](https://travis-ci.org/strongloop/node-foreman) - -Node Foreman is a Node.js version of the popular -[Foreman](http://ddollar.github.com/foreman/) tool, -with a few Node specific changes. - -> Foreman is a manager for Procfile-based applications. -> Its aim is to abstract away the details of the Procfile -> format, and allow you to either run your application -> directly or export it to some other process management format. - -## Install - -Install the command line tool - - npm install -g foreman - -Get usage - - nf --help - -## Deviations from the original Foreman - -* Each worker has an additional automatic environment variable, - `FOREMAN_WORKER_NAME`, that contains the process name and worker number. - * example: `web.1`, `worker.1` - -### How to Contribute - -I encourage anyone and everyone to help. -If you have a specific change in mind, open an issue; we can talk about it there. - -If you would like to make a code change, go ahead. -Fork the repository, open a pull request. -Do this early, and talk about the change you want to make. -Maybe we can work together on it. - -Refactor Refactor Refactor! -You are free to add features, or just help clean things up. - -## Usage - -Node Foreman can be run with as little as `nf start`, as long as `npm start` has been defined. -For more complicated applications you will want to define a `Procfile` for your various server -processes and an `.env` file to pre-load environmental variables. - -Your module directory should end up looking like the following: - -![List Foreman Directory](https://raw.github.com/strongloop/node-foreman/master/assets/foreman-ls.png) - -Once your `Procfile` is defined, run your application with `nf start`: - -![Start Foreman](https://raw.github.com/strongloop/node-foreman/master/assets/foreman-start.png) - -Node Foreman _always_ starts in the foreground and expects your applications -to do the same. If your processes exit, Node Foreman will assume an error -has occurred and shut your application down. - -Instead of daemonizing, you should use `nf export` to ready your application -for production. - -For more information try any of the following: - - $ nf --help - $ nf start --help - $ nf run --help - $ nf export --help - -### Procfile - -The `Procfile` format is a simple `key : command` format: - - web: node web_server.js - api: node api_server.js - log: node log_server.js - -Each line should contain a separate process. - -### Environmental Variables - -Create a `.env` file to pre-load environmental variables with the format: - - MYSQL_NAME=superman - MYSQL_PASS=cryptonite - -The equivalent `.env` file may alternatively be a valid JSON document: - - { - "mysql":{ - "name": "superman", - "pass": "cryptonite" - } - } - -The above JSON document will be flattened into env variables by -concatenating the nested values with an underscore. -Environmental variables are passed in fully capitalized. - - { - "mysql":{ - "name": "superman", # => MYSQL_NAME=superman - "pass": "cryptonite" # => MYSQL_PASS=cryptonite - } - } - -There is no need to specify which type of file you wish to use. - -#### The PATH environment variable - -The `PATH` variable is given special treatment and is always read -from the environment that the `nf` command has been executed from, -rather than your `.env` file. To set a different `PATH` execute -`nf` with the `PATH` variable set appropriately. - -```bash -PATH=/opt/foo:/opt/bar:$PATH nf export -``` - -#### Best Practices - -Generally you should not check your `.env` file into version control. -The `.env` file contain _only_ parameters that depend on where the application -gets deployed. It should not contain anything related to _how_ the application -is deployed. - -For example, good candidates for the `.env` file are MySQL connection information, -port bindings, and other passwords. - -### The Run Command - -Tasks or commands that require the environment variables from the `.env` file -can be initiated by using `nf run `. - -### Advanced Usage - -Node Foreman lets you start multiple jobs of the same type: - - $ nf start web=5 - - 18:51:12: web.1 | Web Server started listening on 0.0.0.0:5000 - 18:51:12: web.2 | Web Server started listening on 0.0.0.0:5001 - 18:51:12: web.3 | Web Server started listening on 0.0.0.0:5002 - 18:51:12: web.4 | Web Server started listening on 0.0.0.0:5003 - 18:51:12: web.5 | Web Server started listening on 0.0.0.0:5004 - -Each job will be started as its own process, receiving a different `PORT` -environmental variable. -The port number for processes of the same type will be offset by 1. -The port number for processes of different types will be offset by 100. - - $ nf start web=2,api=2 - - 18:51:12: web.1 | Web Server started listening on 0.0.0.0:5000 - 18:51:12: web.2 | Web Server started listening on 0.0.0.0:5001 - 18:51:12: api.1 | Api Server started listening on 0.0.0.0:5100 - 18:51:12: api.2 | Api Server started listening on 0.0.0.0:5101 - -## Export to Production - -Node Foreman is designed to be in a development environment, -however it can export an Upstart job for use in production. -The Upstart file has _no_ dependency on Node Foreman. - - $ nf export - Loaded ENV .env File as JSON Format - Wrote : ./foreman-web-1.conf - Wrote : ./foreman-web.conf - Wrote : ./foreman-api-1.conf - Wrote : ./foreman-api.conf - Wrote : ./foreman-log-1.conf - Wrote : ./foreman-log.conf - Wrote : ./foreman.conf - -You can inspect your upstart files before placing them in the right -directory, or have foreman do it for you: - - $ sudo nf export -o /etc/init - Loaded ENV .env File as JSON Format - Wrote : /etc/init/foreman-api-1.conf - Wrote : /etc/init/foreman-web.conf - Wrote : /etc/init/foreman-api.conf - Wrote : /etc/init/foreman-log.conf - Wrote : /etc/init/foreman-log-1.conf - Wrote : /etc/init/foreman-web-1.conf - Wrote : /etc/init/foreman.conf - -Start and stop your jobs with - - $ sudo start foreman - Starting foreman... ok - $ sudo stop foreman - -The export will occur with whatever environmental variables are -listed in the .env file. - -### systemd Support - -_This section is beta_ - -Optionally specify a type `-t systemd` during export for [systemd](http://www.freedesktop.org/wiki/Software/systemd) support. - -### Supervisord Support - -You can also use a type `-t supervisord` during export for [supervisord](http://www.supervisord.org) support. - -This will generate a `APP.conf` file grouping the application processes and a `APP-PROCESS-N.conf` file for each process. - - $ nf export --type supervisord - Loaded ENV .env File as JSON Format - Wrote : ./foreman-web-1.conf - Wrote : ./foreman-api-1.conf - Wrote : ./foreman-log-1.conf - Wrote : ./foreman.conf - -You can start / stop / restart individual processes. - - $ sudo supervisorctl start 'foreman:foreman-web-1' - $ sudo supervisorctl stop 'foreman:foreman-web-1' - $ sudo supervisorctl restart 'foreman:foreman-web-1' - -Or the entire group of processes - - $ sudo supervisorctl start 'foreman:*' - $ sudo supervisorctl stop 'foreman:*' - $ sudo supervisorctl restart 'foreman:*' - -### Advanced Exports - -You can specify the type and number of processes exported using -the `type=num` syntax: - - $ nf export web=2,api=2 - -Use `-u ` to have the exported job run as `USER`. -Note that if you need to bind to privileged ports, you _must_ -start as `root`. In such a case, we advise you to drop user -permissions after binding. - -If you want to call your upstart job something other than foreman, -use `-a ` and manage your jobs with `sudo start `. - -## Reverse Proxy - -Node.js processes are supposed to be stateless. -Applications scale by starting multiple processes that either share a socket, -or sit behind a load balancer. -Node Foreman can help you test the parallel capabilities of your application -by spawning multiple processes behind a round-robin proxy. - - $ nf start -x 8888 web=5 - [OKAY] Starting Proxy Server 8888 -> 5000-5004 - -Access your application from port `8888` and the connections will be balanced -across the servers started from ports `5000` - `5004`. - -If your application gets its port number from `process.env.PORT` the proxy -setup will happen automatically. - -### Multiple Reverse Proxies - -If you have multiple processes in your `Procfile` you can start multiple proxies. - - $ nf start -x 8888,8080,9090 - -This will start 3 separate proxies and bind each to a separate process group. -Proxies are bound based on their order specified, their order in the Procfile, -or by their order on the command line. - - $ nf start -x 8888,9999 web,api - -### Privileged Ports - -Node Foreman disallows applications from starting on privileged ports. -It does however allow proxies to be bound to lower ports, such as port 80. - -If you require access to a privileged port, start Node Foreman with `sudo`: - - $ sudo nf start -x 80 web=5 - [OKAY] Starting Proxy Server 80 -> 5000-5004 - -Your application will then be accessible via port 80, but it will be running as root. - -## Forward Proxy - -Local development and testing has huge advantages, -but sometimes one needs to test web applications against their real-world domain name. -Editing `/etc/hosts` is a pain however, and error prone. - -Node Foreman can start up an HTTP forward proxy which your browser can route requests through. -The forward proxy will intercept requests based on domain name, and route them to the local application. - - $ nf start -f 9999 -i nodefly.com - [OKAY] Forward Proxy Started in Port 9999 - [OKAY] Intercepting requests to nodefly.com through forward proxy - -A forward proxy is useful when testing OAuth, or other external services with application callbacks. - -For users with Google Chrome, this can be paired with [FelisCatus SwitchyOmega](https://github.com/FelisCatus/SwitchyOmega) for great results. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7dd9233..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,19 +0,0 @@ -environment: - matrix: - - nodejs_version: '10' - - nodejs_version: '8' - - nodejs_version: '6' -install: - - ps: Install-Product node $env:nodejs_version - - set CI=true - - npm -g install npm@latest - - set PATH=%APPDATA%\npm;%PATH% - - npm install -matrix: - fast_finish: true -build: off -version: '{build}' -shallow_clone: true -clone_depth: 1 -test_script: - - npm test -- -Rclassic --no-coverage --timeout=3600 diff --git a/assets/foreman-ls.png b/assets/foreman-ls.png deleted file mode 100644 index d2ae228..0000000 Binary files a/assets/foreman-ls.png and /dev/null differ diff --git a/assets/foreman-start.png b/assets/foreman-start.png deleted file mode 100644 index a7d1cd3..0000000 Binary files a/assets/foreman-start.png and /dev/null differ diff --git a/demo/.env b/demo/.env deleted file mode 100644 index f5ca76c..0000000 --- a/demo/.env +++ /dev/null @@ -1,9 +0,0 @@ -{ - "port": 80, - "bind": "0.0.0.0", - "mysql":{ - "host":"localhost", - "user":"toast", - "pass":"peanutbutter" - } -} diff --git a/demo/Procfile b/demo/Procfile deleted file mode 100644 index 605c0cb..0000000 --- a/demo/Procfile +++ /dev/null @@ -1,3 +0,0 @@ -web: node server.js 5000 -api: node server.js 10000 -log: node server.js 100000 diff --git a/demo/server.js b/demo/server.js deleted file mode 100644 index 5f39a19..0000000 --- a/demo/server.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var http = require('http'); -var env = process.env; - -console.log("Starting Server"); -console.log("Listening to Port", env.PORT); -console.log("Listening to Address", env.BIND); -console.log("Conncting to MySQL '%s' as '%s' with Password '%s'", - env.MYSQL_HOST, - env.MYSQL_USER, - env.MYSQL_PASS); -console.log("Well, the way they make shows is, they make one show. That show's called a pilot. Then they show that show to the people who make shows, and on the strength of that one show they decide if they're going to make more shows. Some pilots get picked and become television programs. Some don't, become nothing. She starred in one of the ones that became nothing."); - -http.createServer(function(req,res){ - console.log("Ping"); - res.write("PONG\n"); - res.end(); -}).listen(process.env.PORT); diff --git a/fonts/OpenSans-Bold-webfont.eot b/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 0000000..e1c7674 Binary files /dev/null and b/fonts/OpenSans-Bold-webfont.eot differ diff --git a/fonts/OpenSans-Bold-webfont.svg b/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 0000000..364b368 --- /dev/null +++ b/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Bold-webfont.ttf b/fonts/OpenSans-Bold-webfont.ttf new file mode 100644 index 0000000..2d94f06 Binary files /dev/null and b/fonts/OpenSans-Bold-webfont.ttf differ diff --git a/fonts/OpenSans-Bold-webfont.woff b/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 0000000..cd86852 Binary files /dev/null and b/fonts/OpenSans-Bold-webfont.woff differ diff --git a/fonts/OpenSans-BoldItalic-webfont.eot b/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 0000000..f44ac9a Binary files /dev/null and b/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/fonts/OpenSans-BoldItalic-webfont.svg b/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 0000000..8392240 --- /dev/null +++ b/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-BoldItalic-webfont.ttf b/fonts/OpenSans-BoldItalic-webfont.ttf new file mode 100644 index 0000000..f74e0e3 Binary files /dev/null and b/fonts/OpenSans-BoldItalic-webfont.ttf differ diff --git a/fonts/OpenSans-BoldItalic-webfont.woff b/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 0000000..f3248c1 Binary files /dev/null and b/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/fonts/OpenSans-Italic-webfont.eot b/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 0000000..277c189 Binary files /dev/null and b/fonts/OpenSans-Italic-webfont.eot differ diff --git a/fonts/OpenSans-Italic-webfont.svg b/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 0000000..29c7497 --- /dev/null +++ b/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Italic-webfont.ttf b/fonts/OpenSans-Italic-webfont.ttf new file mode 100644 index 0000000..63f187e Binary files /dev/null and b/fonts/OpenSans-Italic-webfont.ttf differ diff --git a/fonts/OpenSans-Italic-webfont.woff b/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 0000000..469a29b Binary files /dev/null and b/fonts/OpenSans-Italic-webfont.woff differ diff --git a/fonts/OpenSans-Light-webfont.eot b/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 0000000..837daab Binary files /dev/null and b/fonts/OpenSans-Light-webfont.eot differ diff --git a/fonts/OpenSans-Light-webfont.svg b/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 0000000..bdb6726 --- /dev/null +++ b/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Light-webfont.ttf b/fonts/OpenSans-Light-webfont.ttf new file mode 100644 index 0000000..b50ef9d Binary files /dev/null and b/fonts/OpenSans-Light-webfont.ttf differ diff --git a/fonts/OpenSans-Light-webfont.woff b/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 0000000..99514d1 Binary files /dev/null and b/fonts/OpenSans-Light-webfont.woff differ diff --git a/fonts/OpenSans-LightItalic-webfont.eot b/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 0000000..f0ebf2c Binary files /dev/null and b/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/fonts/OpenSans-LightItalic-webfont.svg b/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 0000000..60765da --- /dev/null +++ b/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-LightItalic-webfont.ttf b/fonts/OpenSans-LightItalic-webfont.ttf new file mode 100644 index 0000000..5898c8c Binary files /dev/null and b/fonts/OpenSans-LightItalic-webfont.ttf differ diff --git a/fonts/OpenSans-LightItalic-webfont.woff b/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 0000000..9c978dc Binary files /dev/null and b/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/fonts/OpenSans-Regular-webfont.eot b/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 0000000..dd6fd2c Binary files /dev/null and b/fonts/OpenSans-Regular-webfont.eot differ diff --git a/fonts/OpenSans-Regular-webfont.svg b/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 0000000..01038bb --- /dev/null +++ b/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Regular-webfont.ttf b/fonts/OpenSans-Regular-webfont.ttf new file mode 100644 index 0000000..05951e7 Binary files /dev/null and b/fonts/OpenSans-Regular-webfont.ttf differ diff --git a/fonts/OpenSans-Regular-webfont.woff b/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 0000000..274664b Binary files /dev/null and b/fonts/OpenSans-Regular-webfont.woff differ diff --git a/fonts/OpenSans-Semibold-webfont.eot b/fonts/OpenSans-Semibold-webfont.eot new file mode 100644 index 0000000..289aade Binary files /dev/null and b/fonts/OpenSans-Semibold-webfont.eot differ diff --git a/fonts/OpenSans-Semibold-webfont.svg b/fonts/OpenSans-Semibold-webfont.svg new file mode 100644 index 0000000..cc2ca42 --- /dev/null +++ b/fonts/OpenSans-Semibold-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 2011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Semibold-webfont.ttf b/fonts/OpenSans-Semibold-webfont.ttf new file mode 100644 index 0000000..6f15073 Binary files /dev/null and b/fonts/OpenSans-Semibold-webfont.ttf differ diff --git a/fonts/OpenSans-Semibold-webfont.woff b/fonts/OpenSans-Semibold-webfont.woff new file mode 100644 index 0000000..4e47cb1 Binary files /dev/null and b/fonts/OpenSans-Semibold-webfont.woff differ diff --git a/fonts/OpenSans-SemiboldItalic-webfont.eot b/fonts/OpenSans-SemiboldItalic-webfont.eot new file mode 100644 index 0000000..50a8a6f Binary files /dev/null and b/fonts/OpenSans-SemiboldItalic-webfont.eot differ diff --git a/fonts/OpenSans-SemiboldItalic-webfont.svg b/fonts/OpenSans-SemiboldItalic-webfont.svg new file mode 100644 index 0000000..65b50e2 --- /dev/null +++ b/fonts/OpenSans-SemiboldItalic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-SemiboldItalic-webfont.ttf b/fonts/OpenSans-SemiboldItalic-webfont.ttf new file mode 100644 index 0000000..55ba312 Binary files /dev/null and b/fonts/OpenSans-SemiboldItalic-webfont.ttf differ diff --git a/fonts/OpenSans-SemiboldItalic-webfont.woff b/fonts/OpenSans-SemiboldItalic-webfont.woff new file mode 100644 index 0000000..0adc6df Binary files /dev/null and b/fonts/OpenSans-SemiboldItalic-webfont.woff differ diff --git a/forward.js b/forward.js deleted file mode 100644 index 2243c37..0000000 --- a/forward.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var http = require('http'); -var url = require('url'); -var httpProxy = require('http-proxy'); - -function startForward(proxy_port, proxy_host) { - - var proxy = httpProxy.createProxyServer({}); - - var httpServer = http.createServer(function(req, res) { - - var _url = url.parse(req.url); - - var dest = _url.hostname; - var port = _url.port || 80; - var host = '127.0.0.1'; - - var target; - if(proxy_host === '' || proxy_host === dest) { - - target = { - host: host, - port: port - }; - req.url = _url.path; - - } else { - target = { - host: dest, - port: port - }; - } - - proxy.web(req, res, {target: target}); - - }); - - proxy.on('upgrade', function (req, socket, head) { - proxy.ws(req, socket, head); - }); - - proxy.on('error', function(err, req, res){ - console.error('Proxy Error: ', err); - res.writeHead(500); - res.write('Upstream Proxy Error'); - res.end(); - }); - - httpServer.listen(proxy_port); -} - -startForward(process.env.PROXY_PORT, process.env.PROXY_HOST); diff --git a/images/bullet.png b/images/bullet.png new file mode 100644 index 0000000..22ea543 Binary files /dev/null and b/images/bullet.png differ diff --git a/images/hr.gif b/images/hr.gif new file mode 100644 index 0000000..bdb4168 Binary files /dev/null and b/images/hr.gif differ diff --git a/images/nav-bg.gif b/images/nav-bg.gif new file mode 100644 index 0000000..4743965 Binary files /dev/null and b/images/nav-bg.gif differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..e78bef4 --- /dev/null +++ b/index.html @@ -0,0 +1,385 @@ + + + + + + node-foreman by strongloop + + + + + + + +
+
+

node-foreman

+

A Node.js Version of Foreman

+ +

View the Project on GitHub strongloop/node-foreman

+ + + +
+
+

+Node Foreman Build Status +

+ +

Node Foreman is a Node.js version of the popular +Foreman tool, +with a few Node specific changes.

+ +
+

Foreman is a manager for Procfile-based applications. +Its aim is to abstract away the details of the Procfile +format, and allow you to either run your application +directly or export it to some other process management format.

+
+ +

+Install

+ +

Install the command line tool

+ +
$ npm install -g foreman
+
+ +

+Deviations from the original Foreman

+ +
    +
  • Each worker has an additional automatic environment variable, +FOREMAN_WORKER_NAME, that contains the the process name and worker number. + +
      +
    • example: web.1, worker.1 +
    • +
    +
  • +

+How to Contribute

+ +

I encourage anyone and everyone to help. +If you have a specific change in mind, open an issue; we can talk about it there.

+ +

If you would like to make a code change, go ahead. +Fork the repository, open a pull request. +Do this early, and talk about the change you want to make. +Maybe we can work together on it.

+ +

Refactor Refactor Refactor! +You are free to add features, or just help clean things up.

+ +

+Usage

+ +

Node Foreman can be run with as little as nf start, as long as npm start has been defined. +For more complicated applications you will want to define a Procfile for your various server +processes and and a .env file to preload environmental variables.

+ +

Your module directory should end up looking like the following:

+ +

List Foreman Directory

+ +

Once your Procfile is defined, run your application with nf start:

+ +

Start Foreman

+ +

Node Foreman always starts in the foreground and expects your applications +to do the same. If your processes exit, Node Foreman will assume an error +has ocurred and shut your application down.

+ +

Instead of daemonizing, you should use nf export to ready your application +for production.

+ +

For more information try any of the following:

+ +
$ nf --help
+$ nf start --help
+$ nf export --help
+
+ +

+Procfile

+ +

The Procfile format is a simple key : command format:

+ +
web: node web_server.js
+api: node api_server.js
+log: node log_server.js
+
+ +

Each line should contain a separate process.

+ +

+Environmental Variables

+ +

Create a .env file to pre-load environmental variables with the format:

+ +
MYSQL_NAME=superman
+MYSQL_PASS=cryptonite
+
+ +

The equivalent .env file may alternatively be a valid JSON document:

+ +
{
+    "mysql":{
+        "name": "superman",
+        "pass": "cryptonite"
+    }
+}
+
+ +

The above JSON document will be flattened into env variables by +concatenating the nested values with an underscore. +Environmental variables are passed in fully capitalized.

+ +
{
+    "mysql":{
+        "name": "superman",     # => MYSQL_NAME=superman
+        "pass": "cryptonite"    # => MYSQL_PASS=cryptonite
+    }
+}
+
+ +

There is no need to specify which type of file you wish to use.

+ +

+The PATH environment variable

+ +

The PATH variable is given special treament and is always read +from the environment that the nf command has been executed from, +rather than a .env file. To set a different PATH execute +nf with the PATH variable set appropriately.

+ +
PATH=/opt/foo:/opt/bar:$PATH nf export
+
+ +

+Best Practices

+ +

Generally you should not check your .env file into version control. +The .env file contain only parameters that depend on where the application +gets deployed. It should not contain anything related to how the application +is deployed.

+ +

For example, good candidates for the .env file are MySQL connection information, +port bindings, and other passwords.

+ +

+Advanced Usage

+ +

Node Foreman lets you start multiple jobs of the same type:

+ +
$ nf start web=5
+
+18:51:12: web.1     |  Web Server started listening on 0.0.0.0:5000
+18:51:12: web.2     |  Web Server started listening on 0.0.0.0:5001
+18:51:12: web.3     |  Web Server started listening on 0.0.0.0:5002
+18:51:12: web.4     |  Web Server started listening on 0.0.0.0:5003
+18:51:12: web.5     |  Web Server started listening on 0.0.0.0:5004
+
+ +

Each job will be started as its own process, receiving a different PORT +environmental variable. +The port number for processes of the same type will be offset by 1. +The port number for processes of different types will be offset by 100.

+ +
$ nf start web=2,api=2
+
+18:51:12: web.1     |  Web Server started listening on 0.0.0.0:5000
+18:51:12: web.2     |  Web Server started listening on 0.0.0.0:5001
+18:51:12: api.1     |  Api Server started listening on 0.0.0.0:5100
+18:51:12: api.2     |  Api Server started listening on 0.0.0.0:5101
+
+ +

+Export to Production

+ +

Node Foreman is designed to be in a development environment, +however it can export an Upstart job for use in production. +The Upstart file has no dependency on Node Foreman.

+ +
$ nf export
+Loaded ENV .env File as JSON Format
+Wrote  :  ./foreman-web-1.conf
+Wrote  :  ./foreman-web.conf
+Wrote  :  ./foreman-api-1.conf
+Wrote  :  ./foreman-api.conf
+Wrote  :  ./foreman-log-1.conf
+Wrote  :  ./foreman-log.conf
+Wrote  :  ./foreman.conf
+
+ +

You can inspect your upstart files before placing them in the right +directory, or have foreman do it for you:

+ +
$ sudo nf export -o /etc/init
+Loaded ENV .env File as JSON Format
+Wrote  :  /etc/init/foreman-api-1.conf
+Wrote  :  /etc/init/foreman-web.conf
+Wrote  :  /etc/init/foreman-api.conf
+Wrote  :  /etc/init/foreman-log.conf
+Wrote  :  /etc/init/foreman-log-1.conf
+Wrote  :  /etc/init/foreman-web-1.conf
+Wrote  :  /etc/init/foreman.conf
+
+ +

Start and stop your jobs with

+ +
$ sudo start foreman
+$ sudo stop foreman
+
+ +

The export will occur with whatever environmental variables are +listed in the .env file.

+ +

+Systemd Support

+ +

This section is beta

+ +

Optionally specify a type -t systemd during export for systemd support.

+ +

+Supervisord Support

+ +

You can also use a type -t supervisord during export for supervisord support.

+ +

This will generate a APP.conf file grouping the application processes and a APP-PROCESS-N.conf file for each process.

+ +
$ nf export --type supervisord
+Loaded ENV .env File as JSON Format
+Wrote  :  ./foreman-web-1.conf
+Wrote  :  ./foreman-api-1.conf
+Wrote  :  ./foreman-log-1.conf
+Wrote  :  ./foreman.conf
+
+ +

You can start / stop / restart individual processes.

+ +
$ sudo supervisorctl start 'foreman:foreman-web-1'
+$ sudo supervisorctl stop 'foreman:foreman-web-1'
+$ sudo supervisorctl restart 'foreman:foreman-web-1'
+
+ +

Or the entire group of processes

+ +
$ sudo supervisorctl start 'foreman:*'
+$ sudo supervisorctl stop 'foreman:*'
+$ sudo supervisorctl restart 'foreman:*'
+
+ +

+Advanced Exports

+ +

You can specify the type and number of processes exported using +the type=num syntax:

+ +
$ nf export web=2,api=2
+
+ +

Use -u <USER> to have the exported job run as USER. +Note that if you need to bind to privileged ports, you must +start as root. In such a case, we advise you to drop user +permissions after binding.

+ +

If you want to call your upstart job something other than foreman, +use -a <JOBNAME> and manage your jobs with sudo start <JOBNAME>.

+ +

+Reverse Proxy

+ +

Node.js processes are supposed to be stateless. +Application scale by starting multiple processes that either share a socket, +or sit behind a load balancer. +Node Foreman can help you test the parallel capabilities of your application +by spawning multiple processes behind a round-robin proxy automatically.

+ +
$ nf start -x 8888 web=5
+[OKAY] Starting Proxy Server 8888 -> 5000-5004
+
+ +

Access your application from port 8888 and the connections will be balanced +across the servers started from ports 5000 - 5004.

+ +

If your application gets its port number from process.env.PORT the proxy +setup will ocurr automatically.

+ +

+Multiple Reverse Proxies

+ +

If you have multiple processes in your Procfile you can start multiple proxies.

+ +
$ nf start -x 8888,8080,9090
+
+ +

This will start 3 separate proxies and bind each to a separate process group. +Proxies are bound based on their order specified, their order in the Procfile, +or by their order on the command line.

+ +
$ nf start -x 8888,9999 web,api
+
+ +

+Privileged Ports

+ +

Node Foreman disallows applications from starting on privileged ports. +It does however allow proxies to be bound to lower ports, such as port 80.

+ +

If you require access to a privileged port, start Node Foreman with sudo:

+ +
$ sudo nf start -x 80 web=5
+[OKAY] Starting Proxy Server 80 -> 5000-5004
+
+ +

Your application will then be accessible via port 80.

+ +

Your applications will still be started in user space, and the proxy will +drop its privileges after binding to the privileged port.

+ +

+Forward Proxy

+ +

Local development and testing has huge advantages, +but sometimes one needs to test web applications agains their real-world domain name. +Editing /etc/hosts is a pain however, and error prone.

+ +

Node Foreman can start up an HTTP forward proxy which your browser can route requests through. +The forward proxy will intercept requests based on domain name, and route them to the local application.

+ +
$ nf start -f 9999 -h nodefly.com
+[OKAY] Forward Proxy Started in Port 9999
+[OKAY] Intercepting requests to nodefly.com through forward proxy
+
+ +

A forward proxy is useful when testing OAuth, or other external services with application callbacks.

+ +

For users with Google Chrome, this can be paired with Proxy Switch Sharp for great results.

+
+ +
+ + + + + + \ No newline at end of file diff --git a/javascripts/respond.js b/javascripts/respond.js new file mode 100644 index 0000000..76bc260 --- /dev/null +++ b/javascripts/respond.js @@ -0,0 +1,779 @@ +if(typeof Object.create!=="function"){ +Object.create=function(o){ +function F(){ +}; +F.prototype=o; +return new F(); +}; +} +var ua={toString:function(){ +return navigator.userAgent; +},test:function(s){ +return this.toString().toLowerCase().indexOf(s.toLowerCase())>-1; +}}; +ua.version=(ua.toString().toLowerCase().match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1]; +ua.webkit=ua.test("webkit"); +ua.gecko=ua.test("gecko")&&!ua.webkit; +ua.opera=ua.test("opera"); +ua.ie=ua.test("msie")&&!ua.opera; +ua.ie6=ua.ie&&document.compatMode&&typeof document.documentElement.style.maxHeight==="undefined"; +ua.ie7=ua.ie&&document.documentElement&&typeof document.documentElement.style.maxHeight!=="undefined"&&typeof XDomainRequest==="undefined"; +ua.ie8=ua.ie&&typeof XDomainRequest!=="undefined"; +var domReady=function(){ +var _1=[]; +var _2=function(){ +if(!arguments.callee.done){ +arguments.callee.done=true; +for(var i=0;i<_1.length;i++){ +_1[i](); +} +} +}; +if(document.addEventListener){ +document.addEventListener("DOMContentLoaded",_2,false); +} +if(ua.ie){ +(function(){ +try{ +document.documentElement.doScroll("left"); +} +catch(e){ +setTimeout(arguments.callee,50); +return; +} +_2(); +})(); +document.onreadystatechange=function(){ +if(document.readyState==="complete"){ +document.onreadystatechange=null; +_2(); +} +}; +} +if(ua.webkit&&document.readyState){ +(function(){ +if(document.readyState!=="loading"){ +_2(); +}else{ +setTimeout(arguments.callee,10); +} +})(); +} +window.onload=_2; +return function(fn){ +if(typeof fn==="function"){ +_1[_1.length]=fn; +} +return fn; +}; +}(); +var cssHelper=function(){ +var _3={BLOCKS:/[^\s{][^{]*\{(?:[^{}]*\{[^{}]*\}[^{}]*|[^{}]*)*\}/g,BLOCKS_INSIDE:/[^\s{][^{]*\{[^{}]*\}/g,DECLARATIONS:/[a-zA-Z\-]+[^;]*:[^;]+;/g,RELATIVE_URLS:/url\(['"]?([^\/\)'"][^:\)'"]+)['"]?\)/g,REDUNDANT_COMPONENTS:/(?:\/\*([^*\\\\]|\*(?!\/))+\*\/|@import[^;]+;)/g,REDUNDANT_WHITESPACE:/\s*(,|:|;|\{|\})\s*/g,MORE_WHITESPACE:/\s{2,}/g,FINAL_SEMICOLONS:/;\}/g,NOT_WHITESPACE:/\S+/g}; +var _4,_5=false; +var _6=[]; +var _7=function(fn){ +if(typeof fn==="function"){ +_6[_6.length]=fn; +} +}; +var _8=function(){ +for(var i=0;i<_6.length;i++){ +_6[i](_4); +} +}; +var _9={}; +var _a=function(n,v){ +if(_9[n]){ +var _b=_9[n].listeners; +if(_b){ +for(var i=0;i<_b.length;i++){ +_b[i](v); +} +} +} +}; +var _c=function(_d,_e,_f){ +if(ua.ie&&!window.XMLHttpRequest){ +window.XMLHttpRequest=function(){ +return new ActiveXObject("Microsoft.XMLHTTP"); +}; +} +if(!XMLHttpRequest){ +return ""; +} +var r=new XMLHttpRequest(); +try{ +r.open("get",_d,true); +r.setRequestHeader("X_REQUESTED_WITH","XMLHttpRequest"); +} +catch(e){ +_f(); +return; +} +var _10=false; +setTimeout(function(){ +_10=true; +},5000); +document.documentElement.style.cursor="progress"; +r.onreadystatechange=function(){ +if(r.readyState===4&&!_10){ +if(!r.status&&location.protocol==="file:"||(r.status>=200&&r.status<300)||r.status===304||navigator.userAgent.indexOf("Safari")>-1&&typeof r.status==="undefined"){ +_e(r.responseText); +}else{ +_f(); +} +document.documentElement.style.cursor=""; +r=null; +} +}; +r.send(""); +}; +var _11=function(_12){ +_12=_12.replace(_3.REDUNDANT_COMPONENTS,""); +_12=_12.replace(_3.REDUNDANT_WHITESPACE,"$1"); +_12=_12.replace(_3.MORE_WHITESPACE," "); +_12=_12.replace(_3.FINAL_SEMICOLONS,"}"); +return _12; +}; +var _13={mediaQueryList:function(s){ +var o={}; +var idx=s.indexOf("{"); +var lt=s.substring(0,idx); +s=s.substring(idx+1,s.length-1); +var mqs=[],rs=[]; +var qts=lt.toLowerCase().substring(7).split(","); +for(var i=0;i-1&&_23.href&&_23.href.length!==0&&!_23.disabled){ +_1f[_1f.length]=_23; +} +} +if(_1f.length>0){ +var c=0; +var _24=function(){ +c++; +if(c===_1f.length){ +_20(); +} +}; +var _25=function(_26){ +var _27=_26.href; +_c(_27,function(_28){ +_28=_11(_28).replace(_3.RELATIVE_URLS,"url("+_27.substring(0,_27.lastIndexOf("/"))+"/$1)"); +_26.cssHelperText=_28; +_24(); +},_24); +}; +for(i=0;i<_1f.length;i++){ +_25(_1f[i]); +} +}else{ +_20(); +} +}; +var _29={mediaQueryLists:"array",rules:"array",selectors:"object",declarations:"array",properties:"object"}; +var _2a={mediaQueryLists:null,rules:null,selectors:null,declarations:null,properties:null}; +var _2b=function(_2c,v){ +if(_2a[_2c]!==null){ +if(_29[_2c]==="array"){ +return (_2a[_2c]=_2a[_2c].concat(v)); +}else{ +var c=_2a[_2c]; +for(var n in v){ +if(v.hasOwnProperty(n)){ +if(!c[n]){ +c[n]=v[n]; +}else{ +c[n]=c[n].concat(v[n]); +} +} +} +return c; +} +} +}; +var _2d=function(_2e){ +_2a[_2e]=(_29[_2e]==="array")?[]:{}; +for(var i=0;i<_4.length;i++){ +_2b(_2e,_4[i].cssHelperParsed[_2e]); +} +return _2a[_2e]; +}; +domReady(function(){ +var els=document.body.getElementsByTagName("*"); +for(var i=0;i=_44)||(max&&_46<_44)||(!min&&!max&&_46===_44)); +}else{ +return false; +} +}else{ +return _46>0; +} +}else{ +if("device-height"===_41.substring(l-13,l)){ +_47=screen.height; +if(_42!==null){ +if(_43==="length"){ +return ((min&&_47>=_44)||(max&&_47<_44)||(!min&&!max&&_47===_44)); +}else{ +return false; +} +}else{ +return _47>0; +} +}else{ +if("width"===_41.substring(l-5,l)){ +_46=document.documentElement.clientWidth||document.body.clientWidth; +if(_42!==null){ +if(_43==="length"){ +return ((min&&_46>=_44)||(max&&_46<_44)||(!min&&!max&&_46===_44)); +}else{ +return false; +} +}else{ +return _46>0; +} +}else{ +if("height"===_41.substring(l-6,l)){ +_47=document.documentElement.clientHeight||document.body.clientHeight; +if(_42!==null){ +if(_43==="length"){ +return ((min&&_47>=_44)||(max&&_47<_44)||(!min&&!max&&_47===_44)); +}else{ +return false; +} +}else{ +return _47>0; +} +}else{ +if("device-aspect-ratio"===_41.substring(l-19,l)){ +return _43==="aspect-ratio"&&screen.width*_44[1]===screen.height*_44[0]; +}else{ +if("color-index"===_41.substring(l-11,l)){ +var _48=Math.pow(2,screen.colorDepth); +if(_42!==null){ +if(_43==="absolute"){ +return ((min&&_48>=_44)||(max&&_48<_44)||(!min&&!max&&_48===_44)); +}else{ +return false; +} +}else{ +return _48>0; +} +}else{ +if("color"===_41.substring(l-5,l)){ +var _49=screen.colorDepth; +if(_42!==null){ +if(_43==="absolute"){ +return ((min&&_49>=_44)||(max&&_49<_44)||(!min&&!max&&_49===_44)); +}else{ +return false; +} +}else{ +return _49>0; +} +}else{ +if("resolution"===_41.substring(l-10,l)){ +var res; +if(_45==="dpcm"){ +res=_3d("1cm"); +}else{ +res=_3d("1in"); +} +if(_42!==null){ +if(_43==="resolution"){ +return ((min&&res>=_44)||(max&&res<_44)||(!min&&!max&&res===_44)); +}else{ +return false; +} +}else{ +return res>0; +} +}else{ +return false; +} +} +} +} +} +} +} +} +}; +var _4a=function(mq){ +var _4b=mq.getValid(); +var _4c=mq.getExpressions(); +var l=_4c.length; +if(l>0){ +for(var i=0;i0){ +s[c++]=","; +} +s[c++]=n; +} +} +if(s.length>0){ +_39[_39.length]=cssHelper.addStyle("@media "+s.join("")+"{"+mql.getCssText()+"}",false); +} +}; +var _4e=function(_4f){ +for(var i=0;i<_4f.length;i++){ +_4d(_4f[i]); +} +if(ua.ie){ +document.documentElement.style.display="block"; +setTimeout(function(){ +document.documentElement.style.display=""; +},0); +setTimeout(function(){ +cssHelper.broadcast("cssMediaQueriesTested"); +},100); +}else{ +cssHelper.broadcast("cssMediaQueriesTested"); +} +}; +var _50=function(){ +for(var i=0;i<_39.length;i++){ +cssHelper.removeStyle(_39[i]); +} +_39=[]; +cssHelper.mediaQueryLists(_4e); +}; +var _51=0; +var _52=function(){ +var _53=cssHelper.getViewportWidth(); +var _54=cssHelper.getViewportHeight(); +if(ua.ie){ +var el=document.createElement("div"); +el.style.position="absolute"; +el.style.top="-9999em"; +el.style.overflow="scroll"; +document.body.appendChild(el); +_51=el.offsetWidth-el.clientWidth; +document.body.removeChild(el); +} +var _55; +var _56=function(){ +var vpw=cssHelper.getViewportWidth(); +var vph=cssHelper.getViewportHeight(); +if(Math.abs(vpw-_53)>_51||Math.abs(vph-_54)>_51){ +_53=vpw; +_54=vph; +clearTimeout(_55); +_55=setTimeout(function(){ +if(!_3a()){ +_50(); +}else{ +cssHelper.broadcast("cssMediaQueriesTested"); +} +},500); +} +}; +window.onresize=function(){ +var x=window.onresize||function(){ +}; +return function(){ +x(); +_56(); +}; +}(); +}; +var _57=document.documentElement; +_57.style.marginLeft="-32767px"; +setTimeout(function(){ +_57.style.marginTop=""; +},20000); +return function(){ +if(!_3a()){ +cssHelper.addListener("newStyleParsed",function(el){ +_4e(el.cssHelperParsed.mediaQueryLists); +}); +cssHelper.addListener("cssMediaQueriesTested",function(){ +if(ua.ie){ +_57.style.width="1px"; +} +setTimeout(function(){ +_57.style.width=""; +_57.style.marginLeft=""; +},0); +cssHelper.removeListener("cssMediaQueriesTested",arguments.callee); +}); +_3c(); +_50(); +}else{ +_57.style.marginLeft=""; +} +_52(); +}; +}()); +try{ +document.execCommand("BackgroundImageCache",false,true); +} +catch(e){ +} + diff --git a/javascripts/scale.fix.js b/javascripts/scale.fix.js new file mode 100644 index 0000000..87a40ca --- /dev/null +++ b/javascripts/scale.fix.js @@ -0,0 +1,17 @@ +var metas = document.getElementsByTagName('meta'); +var i; +if (navigator.userAgent.match(/iPhone/i)) { + for (i=0; i0){ - line = self.trim(line,self.trimline); - } - - var delimiter = " | "; - - var wrapline; - if(self.wrapline === 0) { - wrapline = line.length; - } else { - wrapline = self.wrapline; - } - - wrap(line, wrapline).forEach(function(l) { - logger.log(proc.color(self.pad(stamp,self.padding) + delimiter), l); - delimiter = " | > "; - }); - - }); - }; - - // Foreman Loggers // - - this.Alert = function Alert() { - logger.log(colors.green('[OKAY] '+ this.fmt.apply(null, arguments))); - }; - - this.Done = function Info() { - logger.log(colors.cyan('[DONE] ' + this.fmt.apply(null, arguments))); - }; - - this.Warn = function Warn() { - logger.warn(colors.yellow('[WARN] ' + this.fmt.apply(null, arguments))); - }; - - this.Error = function Error() { - logger.error(colors.bright_red('[FAIL] ' + this.fmt.apply(null,arguments))); - }; - -} - -module.exports = Console; -Console.Console = new Console(); diff --git a/lib/envs.js b/lib/envs.js deleted file mode 100644 index 2b8e675..0000000 --- a/lib/envs.js +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var fs = require('fs'); -var util = require('util'); -var cons = require('./console').Console; - -function method(name) { - return function(o) { - return o[name].apply(o); - }; -} - -// Parse a Key=Value File Containing Environmental Variables -function keyValue(data) { - var env = {}; - - data - .toString() - .replace(/^\s*\#.*$/gm,'') - .replace(/^\s*$/gm,'') - .split(/\n/) - .map(method('trim')) - .filter(notBlank) - .forEach(capturePair); - - return env; - - function notBlank(str) { - return str.length > 2; - } - - function capturePair(line) { - var pair = line.split('='); - var key = pair[0].trim(); - var rawVal = pair.slice(1).join('=').trim(); - env[key] = parseValue(rawVal); - } - - function parseValue(val) { - switch (val[0]) { - case '"': return /^"([^"]*)"/.exec(val)[1]; - case "'": return /^'([^']*)'/.exec(val)[1]; - default : return val.replace(/\s*\#.*$/, ''); - } - } -} - -// Given: -/* -{ - "top": { - "middle": { - "bottom": "value" - }, - "other": [ "zero", "one", "two" ] - }, - "last": 42 -} -*/ -// Get: -/* -{ - "TOP_MIDDLE_BOTTOM": "value", - "TOP_OTHER_0": "zero", - "TOP_OTHER_1": "one", - "TOP_OTHER_2": "two", - "LAST": 42 -} -*/ -// Flatten nested object structure -function flattenJSON(json) { - var flattened = {}; - - walk(json, function(path, item) { - flattened[path.join('_').toUpperCase()] = item; - }); - - return flattened; - - function walk(obj, visitor, path) { - var item; - path = path || []; - for (var key in obj) { - item = obj[key]; - if (typeof item === 'object') { - walk(item, visitor, path.concat(key)); - } else { - visitor(path.concat(key), item); - } - } - } -} - - -// Given a standard dictionary: -/* -{ - "TOP_MIDDLE_BOTTOM": "value", - "TOP_OTHER_0": "zero", - "TOP_OTHER_1": "one", - "TOP_OTHER_2": "two", - "LAST": 42 -} -*/ -// Return a key=value pair document -/* -TOP_MIDDLE_BOTTOM=value -TOP_OTHER_0=zero -TOP_OTHER_1=one -TOP_OTHER_2=two -LAST=42 -*/ -function dumpEnv(conf) { - var output = []; - for (var key in conf) { - output.push(key + '=' + conf[key]); - } - return output.sort().join('\n') + '\n'; -} - -// Loads a file as either a .env format or JSON format and returns it as a -// simplified dictionary -function loadEnvsFile(path) { - var env, data; - - if(!fs.existsSync(path)) { - env = {}; - } else { - data = fs.readFileSync(path); - try { - var envs_json = JSON.parse(data); - env = flattenJSON(envs_json, "", {}); - cons.Alert("Loaded ENV %s File as JSON Format", path); - } catch (e) { - env = keyValue(data); - cons.Alert("Loaded ENV %s File as KEY=VALUE Format", path); - } - } - env.PATH = env.PATH || process.env.PATH; - return env; -} - -function loadEnvs(path) { - var envs = path.split(',').map(loadEnvsFile).reduce(util._extend, {}); - var sorted = Object.create(null); - Object.keys(envs).sort().forEach(function(k) { - sorted[k] = envs[k]; - }); - return sorted; -} - -module.exports.loadEnvs = loadEnvs; -module.exports.flattenJSON = flattenJSON; -module.exports.keyValue = keyValue; -module.exports.dumpEnv = dumpEnv; diff --git a/lib/exporters.js b/lib/exporters.js deleted file mode 100644 index d4fc9a3..0000000 --- a/lib/exporters.js +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var colors = require('./colors'); -var ppath = require('path'); -var mu = require('mustache'); -var fs = require('fs'); - -var display = require('./console').Console; - -// Procfile to System Service Export // - -function render(filename, conf, callback) { - fs.readFile(filename, {encoding: 'utf8'}, function(err, template) { - if (err) { - throw err; - } - callback(mu.render(template, conf)); - }); -} - -function templatePath(conf, type, file) { - if(conf.template) { - return ppath.resolve(conf.template, file); - } else { - return ppath.resolve(__dirname, type, file); - } -} - -function writeout(path) { - return function(data) { - if (fs.existsSync(path)) { - display.Warn(colors.bright_yellow('Replacing: %s'), path); - } - - fs.writeFileSync(path,data); - display.Alert('Wrote :',ppath.normalize(path)); - }; -} - -function upstart(conf, outdir) { - var path = outdir + "/" + conf.application + ".conf"; - render(templatePath(conf, 'upstart', 'foreman.conf'), conf, writeout(path)); -} - -function upstart_app(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + ".conf"; - render(templatePath(conf, 'upstart', 'foreman-APP.conf'), conf, writeout(path)); -} - -function upstart_app_n(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + "-" + conf.number + ".conf"; - render(templatePath(conf, 'upstart','foreman-APP-N.conf'), conf, writeout(path)); -} - -function upstart_single(conf, outdir) { - var path = outdir + "/" + conf.application + ".conf"; - render(templatePath(conf, 'upstart-single', 'foreman.conf'), conf, writeout(path)); - display.Warn('upstart-single jobs attempt to raise limits and will fail ' + - 'to start if the limits cannot be raised to the desired ' + - 'levels. Some manual editing may be required.'); -} - -function upstart_single_app(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + ".conf"; - render(templatePath(conf, 'upstart-single', 'foreman-APP.conf'), conf, writeout(path)); -} - -function systemd(conf, outdir){ - var path = outdir + "/" + conf.application + ".target"; - render(templatePath(conf, 'systemd', 'foreman.target'), conf, writeout(path)); -} - -function systemd_app(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + ".target"; - render(templatePath(conf, 'systemd', 'foreman-APP.target'), conf, writeout(path)); -} - -function systemd_app_n(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + "-" + conf.number + ".service"; - render(templatePath(conf, 'systemd', 'foreman-APP-N.service'), conf, writeout(path)); -} - -function supervisord(conf, outdir) { - var path = outdir + "/" + conf.application + ".conf"; - var programs = []; - - // Supervisord requires comma separated lists and they are - // quite ugly to handle in Moustache. - for(var i = 0; i < conf.processes.length; i++) { - var process = conf.processes[i].process; - var n = conf.processes[i].n; - - for(var j = 1; j <= n; j++) { - programs.push(conf.application + "-" + process + "-" + j); - } - } - - conf.programs = programs.join(','); - - render(templatePath(conf, 'supervisord', 'foreman.conf'), conf, writeout(path)); -} - -function supervisord_app_n(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + "-" + conf.number + ".conf"; - var envs = []; - - // We have to do the same thing for env variables. - for(var i in conf.envs) { - var key = conf.envs[i].key; - var value = conf.envs[i].value; - - // Some variables like 'web.1' breaks supervisor confg so we - // escape quotes and wrap values in quotes. - if(typeof value === 'string') { - value = value.replace(/"/, '\\"'); - } - - envs.push(key + "=" + '"' + value + '"'); - } - - conf.envs = envs.join(','); - - render(templatePath(conf, 'supervisord', 'foreman-APP-N.conf'), conf, writeout(path)); -} - -function smf_app(conf, outdir) { - var path = outdir + "/" + conf.application + "-" + conf.process + ".xml"; - render(templatePath(conf, 'smf', 'foreman-APP.xml'), conf, writeout(path)); -} - -var export_formats = { - "upstart": { - foreman : upstart, - foreman_app : upstart_app, - foreman_app_n : upstart_app_n, - }, - "upstart-single": { - foreman : upstart_single, - foreman_app : upstart_single_app, - foreman_app_n : function noop() {}, - }, - "systemd": { - foreman : systemd, - foreman_app : systemd_app, - foreman_app_n : systemd_app_n, - }, - "supervisord": { - foreman : supervisord, - foreman_app : function noop() {}, - foreman_app_n : supervisord_app_n, - }, - "smf": { - foreman : function noop() {}, - foreman_app : smf_app, - foreman_app_n : function noop() {}, - } -}; - -module.exports = export_formats; diff --git a/lib/forward.js b/lib/forward.js deleted file mode 100644 index ae8dabd..0000000 --- a/lib/forward.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var prog = require('child_process'); - -var cons = require('./console').Console; - -function startForward(port, hostname, emitter) { - var proc = prog.fork(__dirname + '/../forward.js', [], { - env: { - PROXY_PORT: port, - PROXY_HOST: hostname || '' - } - }); - cons.Alert('Forward Proxy Started in Port %d', port); - if(hostname) { - cons.Alert('Intercepting requests to %s through forward proxy', hostname); - } else { - cons.Alert('Intercepting ALL requests through forward proxy'); - } - emitter.once('killall', function(signal) { - cons.Done('Killing Forward Proxy Server on Port %d',port); - proc.kill(signal); - }); -} - -module.exports.startForward = startForward; diff --git a/lib/proc.js b/lib/proc.js deleted file mode 100644 index 846887c..0000000 --- a/lib/proc.js +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var prog = require('child_process'); - -var cons = require('./console').Console; - -var _colors = require('./colors'); -var colors_max = _colors.colors_max; -var colors = _colors.colors; - -var os = require('os'); -var platform = os.platform(); - -// Run a Specific Process -// - Key is a Process Name and Number -// - Proc is an object with the launch properties -// -// i.e. web=2 becomes the web.2 key -function run(key, proc, emitter) { - var file, args; - if (platform === 'win32') { - file = process.env.comspec || 'cmd.exe'; - args = ['/s', '/c', proc.command]; - } else { - file = '/bin/sh'; - args = ['-c', proc.command]; - } - var child = prog.spawn(file, args, { env: proc.env }); - var killallReceived = false; - - child.stdout.on('data', function(data) { - cons.log(key, proc, data.toString()); - }); - - child.stderr.on('data', function(data) { - cons.log(key, proc, data.toString()); - }); - - child.on('close', function(code, signal) { - if(code === 0) { - cons.info(key, proc, "Exited Successfully"); - } else { - cons.error(key, proc, "Exited with exit code " + signal || code); - } - }); - - child.on('exit', function(code, signal) { - if (!killallReceived) { - emitter.emit('killall', signal || 'SIGINT'); - } - }); - - emitter.on('killall', function(signal) { - // Once this process has received a killall event, don't send another - // such event to everyone. Let's assume that once is enough. - killallReceived = true; - - try { - child.kill(signal); - } - catch (err) { - if (err.code === 'EPERM') { - // Means that the child runs with higher privileges than we are; we're - // not going to be able to kill it in that state. Log and do nothing. - cons.error(key, proc, "Process has become unkillable; returns EPERM."); - } - } - }); - -} - -// Run a Specific Process Once using the ENV variables -// from the .env file -function once(input, envs, callback) { - var file, args; - var proc = { - command : input, - env : merge(merge({}, process.env), envs) - }; - - if (platform === 'win32') { - file = process.env.comspec || 'cmd.exe'; - args = ['/s', '/c', proc.command]; - } else { - file = '/bin/sh'; - args = ['-c', proc.command]; - } - - var child = prog.spawn(file, args, { env: proc.env, stdio: 'inherit' }); - - child.on('close', function(code) { - callback(code); - }); -} - -// Figure Out What to Start Based on Procfile Processes -// And Requirements Passed as Command Line Arguments -// -// e.g. web=2,api=3 are requirements -function start(procs, requirements, envs, portarg, emitter){ - - var j = 0; - var k = 0; - var port = parseInt(portarg); - - if(port < 1024) { - return cons.Error('Only Proxies Can Bind to Privileged Ports - '+ - 'Try \'sudo nf start -x %s\'', port); - } - - - for(var key in requirements) { - var n = parseInt(requirements[key]); - - for(var i = 0; i < n; i++) { - - var color_val = (j + k) % colors_max; - - if (!procs[key]) { - cons.Warn("Required Key '%s' Does Not Exist in Procfile Definition", key); - continue; - } - - var p = { - command : procs[key], - color : colors[color_val], - env : merge(merge({}, process.env), envs) - }; - - p.env.PORT = port + j + k * 100; - p.env.FOREMAN_WORKER_NAME = p.env.FOREMAN_WORKER_NAME || key + "." + (i + 1); - - run(key + "." + (i + 1), p, emitter); - - j++; - - } - j = 0; - k++; - } -} - -// Merge object b into object a -function merge(a, b) { - if (a && b) { - for (var key in b) { - a[key] = b[key]; - } - } - return a; -} - -module.exports.start = start; -module.exports.run = run; -module.exports.once = once; diff --git a/lib/procfile.js b/lib/procfile.js deleted file mode 100644 index 552677b..0000000 --- a/lib/procfile.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var fs = require('fs'); -var cons = require('./console').Console; -var path = require('path'); - -// Parse Procfile -function procs(procdata){ - - var processes = {}; - - procdata.toString().split(/\n/).forEach(function(line) { - if(!line || line[0] === '#') { return; } - - var tuple = /^([A-Za-z0-9_-]+):\s*(.+)$/m.exec(line); - - var prockey = tuple[1].trim(); - var command = tuple[2].trim(); - - if(!prockey) { - throw new Error('Syntax Error in Procfile, Line %d: No Prockey Found'); - } - - if(!command) { - throw new Error('Syntax Error in Procfile, Line %d: No Command Found'); - } - - processes[prockey] = command; - }); - - return processes; -} - -// Look for a Procfile at the Specified Location -function loadProc(filename) { - - try { - var data = fs.readFileSync(filename); - return procs(data); - } catch(e) { - cons.Warn(e.message); - if(fs.existsSync('package.json')) { - cons.Alert("package.json file found - trying 'npm start'"); - return procs("web: npm start"); - } else { - cons.Error("No Procfile and no package.json file found in Current Directory - See " + path.basename(process.argv[1]) + " --help"); - return; - } - } - -} - -module.exports.loadProc = loadProc; -module.exports.procs = procs; diff --git a/lib/proxy.js b/lib/proxy.js deleted file mode 100644 index cccbae8..0000000 --- a/lib/proxy.js +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var fs = require('fs'); -var path = require('path'); -var prog = require('child_process'); -var util = require('util'); - -var cons = require('./console').Console; - -function f(key, j, ports, proc, reqs, portargs, localhost, emitter, ssl) { - var port = parseInt(ports[j]); - var ssl_port = (port === 80 ? 443 : (port + 443)); - - if(port > 0 && port < 1024 && process.getuid() !== 0) { - return cons.Error('Cannot Bind to Privileged Port %s Without Permission - Try \'sudo\'',port); - } - - if(isNaN(port)) { - return cons.Warn('No Downstream Port Defined for \'%s\' Proxy', key); - } - - if(!(key in proc)) { - return cons.Warn('Proxy Not Started for Undefined Key \'%s\'', key); - } - - var upstream_size = reqs[key]; - var upstream_port = parseInt(portargs) + j * 100; - - var proxy = prog.fork(require.resolve('../proxy'), [], { - env: { - HOST: localhost, - PORT: port, - UPSTREAM_HOST: localhost, - UPSTREAM_PORT: upstream_port, - UPSTREAM_SIZE: upstream_size, - SSL_CERT: ssl.cert, - SSL_KEY: ssl.key, - SSL_PORT: port ? ssl_port : 0 - } - }); - - var port_targets; - - if(upstream_size === 1) { - port_targets = util.format('%d', upstream_port); - } else { - port_targets = util.format('(%d-%d)', upstream_port, upstream_port + upstream_size - 1); - } - - cons.Alert('Starting Proxy Server [%s] %s -> %s', key, port, port_targets); - if (ssl.cert && ssl.key) { - cons.Alert('Starting Secure Proxy Server [%s] %s -> %s', key, ssl_port, port_targets); - } - - proxy.on('message', function(msg) { - if ('http' in msg) { - emitter.emit('http', msg.http); - } - if ('https' in msg) { - emitter.emit('https', msg.https); - } - }); - - emitter.once('killall', function(signal) { - cons.Done('Killing Proxy Server on Port %s', port); - proxy.kill(signal); - }); - - proxy.on('exit', function(code, signal) { - emitter.emit('killall', signal); - }); - -} - -function startProxies(reqs, proc, command, emitter, portargs) { - - if ('proxy' in command) { - - var localhost = 'localhost'; - - var ports = command.proxy.split(','); - - var ssl = { - cert: '', - key: '' - }; - if ((command.sslKey && !command.sslCert) || - (command.sslCert && !command.sslKey)) { - cons.Warn('SSL key and cert must both be supplied for SSL support'); - } - if (command.sslKey && command.sslCert) { - command.sslKey = path.resolve(command.sslKey); - command.sslCert = path.resolve(command.sslCert); - if (!fs.existsSync(command.sslKey)) { - cons.Warn('SSL key (%s) does not exist', command.sslKey); - } - else { - ssl.key = command.sslKey; - } - if (!fs.existsSync(command.sslCert)) { - cons.Warn('SSL cert (%s) does not exist', command.sslCert); - } - else { - ssl.cert = command.sslCert; - } - } - - Object.keys(reqs).forEach(function(key, i) { - f(key, i, ports, proc, reqs, portargs, localhost, emitter, ssl); - }); - } - -} - -module.exports.startProxies = startProxies; diff --git a/lib/requirements.js b/lib/requirements.js deleted file mode 100644 index 552d547..0000000 --- a/lib/requirements.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -function parseRequirements(req) { - var requirements = {}; - req.toString().split(',').forEach(function(item) { - var tup = item.trim().split('='); - var key = tup[0]; - var val; - if(tup.length > 1) { - val = parseInt(tup[1]); - } else { - val = 1; - } - - requirements[key] = val; - }); - return requirements; -} - -function getreqs(args, proc) { - var req; - if(args && args.length > 0) { - // Run Specific Procs - req = parseRequirements(args); - } else { - // All - req = {}; - for(var key in proc){ - req[key] = 1; - } - } - return req; -} - -function calculatePadding(reqs) { - var padding = 0; - for(var key in reqs){ - var num = reqs[key]; - var len = key.length + num.toString().length; - if(len > padding) { - padding = len; - } - } - return padding + 12; -} - -module.exports.calculatePadding = calculatePadding; -module.exports.getreqs = getreqs; diff --git a/lib/smf/foreman-APP.xml b/lib/smf/foreman-APP.xml deleted file mode 100644 index 0ecd6c6..0000000 --- a/lib/smf/foreman-APP.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - {{#envs}} - {{/envs}} - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/supervisord/foreman-APP-N.conf b/lib/supervisord/foreman-APP-N.conf deleted file mode 100644 index f7fed90..0000000 --- a/lib/supervisord/foreman-APP-N.conf +++ /dev/null @@ -1,11 +0,0 @@ -[program:{{{application}}}-{{{process}}}-{{{number}}}] -command={{{ command }}} -autostart=true -autorestart=true -stopsignal=QUIT -stdout_logfile={{{logs}}}/{{{application}}}-{{{process}}}-{{{number}}}.stdout.log -stderr_logfile={{{logs}}}/{{{application}}}-{{{process}}}-{{{number}}}.stderr.log -user={{{user}}} -directory={{{cwd}}} -environment={{{envs}}} - diff --git a/lib/supervisord/foreman.conf b/lib/supervisord/foreman.conf deleted file mode 100644 index d9e9f18..0000000 --- a/lib/supervisord/foreman.conf +++ /dev/null @@ -1,2 +0,0 @@ -[group:{{{application}}}] -programs={{{programs}}} diff --git a/lib/systemd/foreman-APP-N.service b/lib/systemd/foreman-APP-N.service deleted file mode 100644 index 563090b..0000000 --- a/lib/systemd/foreman-APP-N.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description={{{application}}}-{{{process}}}-{{{number}}} -Requires={{{application}}}-{{{process}}}.target - -[Service] -Type=simple -ExecStart=/usr/bin/env {{{command}}} -WorkingDirectory={{{cwd}}} - -User={{{user}}} -Group={{{group}}} - -EnvironmentFile=-{{{envfile}}} -Environment=PORT={{{port}}} - -StandardInput=null -StandardOutput=syslog -StandardError=syslog -Restart=always diff --git a/lib/systemd/foreman-APP.target b/lib/systemd/foreman-APP.target deleted file mode 100644 index dad2cb0..0000000 --- a/lib/systemd/foreman-APP.target +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -Requires={{{application}}}.target -Wants={{#numbers}} {{{application}}}-{{{process}}}-{{{number}}}.service{{/numbers}} diff --git a/lib/systemd/foreman.target b/lib/systemd/foreman.target deleted file mode 100644 index cd62638..0000000 --- a/lib/systemd/foreman.target +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Wants={{#processes}} {{{application}}}-{{{process}}}.target{{/processes}} - -[Install] -WantedBy=multi-user.target diff --git a/lib/upstart-single/foreman-APP.conf b/lib/upstart-single/foreman-APP.conf deleted file mode 100644 index e0c6caa..0000000 --- a/lib/upstart-single/foreman-APP.conf +++ /dev/null @@ -1,57 +0,0 @@ -#{{{application}}}-{{{process}}} - -# Generated by node-foreman - -description "{{{application}}}-{{{process}}} service" - -# Automatic start/stop based on {{{application}}}, which starts on bootup -# To manually start/stop only this job: -# /sbin/initctl start {{{application}}}-{{{process}}} -# /sbin/initctl stop {{{application}}}-{{{process}}} -start on starting {{{application}}} -stop on stopping {{{application}}} -respawn - -# Configuration for this daemon -{{#envs}}env {{{key}}}="{{{value}}}" -{{/envs}} - - -# Not supported by older versions of Upstart, like on RHEL/CentOS -chdir {{{cwd}}} -setuid {{{user}}} -setgid {{{group}}} - -# Arbitrarily high limit on number of open file descriptors -limit nofile 50000 50000 - -# Enable core dumps -limit core unlimited unlimited - -# How to run the application -script - - # Abort if some part of this script fails - set -e - - # Temporary fifo for sending log output to - mkfifo /tmp/{{{application}}}-{{{process}}}-log-fifo - - # A logger instance that pipes the fifo to syslog - ( logger -t {{{application}}}-{{{process}}} /tmp/{{{application}}}-{{{process}}}-log-fifo - - # Clean up the fifo so we don't leave it laying around - rm /tmp/{{{application}}}-{{{process}}}-log-fifo - - # Run our actual application - # - exec used instead of setuid, see comment above - # - stderr redirection is done last so that we don't lose error messages - # related to the Upstart config itself - # Uncomment and use this line if you are using an older version of Upstart - #exec su -m -s /bin/sh -c 'exec "$0" "$@"' {{{user}}} -- npm start 2>&1 - exec {{{command}}} 2>&1 - -end script diff --git a/lib/upstart-single/foreman.conf b/lib/upstart-single/foreman.conf deleted file mode 100644 index 6a8dbc4..0000000 --- a/lib/upstart-single/foreman.conf +++ /dev/null @@ -1,17 +0,0 @@ -#{{{application}}} - -description "{{{application}}} super launcher" - -# Start on boot/reboot up -start on runlevel [2345] - -# Stop on shutdown/reboot -stop on runlevel [016] - -# To start/stop all workers under this app manually you can run: -# -# /sbin/initctl start {{{application}}} -# /sbin/initctl stop {{{application}}} -# -# For instructions on starting/stopping the individual components of this app, -# see the start/stop descriptions in their Upstart job configurations. diff --git a/lib/upstart/foreman-APP-N.conf b/lib/upstart/foreman-APP-N.conf deleted file mode 100644 index fb2ad10..0000000 --- a/lib/upstart/foreman-APP-N.conf +++ /dev/null @@ -1,14 +0,0 @@ -#{{{application}}}-{{{process}}}-{{{number}}} -start on starting {{{application}}}-{{{process}}} -stop on stopping {{{application}}}-{{{process}}} -respawn - -{{#envs}}env {{{key}}}="{{{value}}}" -{{/envs}} - - -chdir {{{cwd}}} -setuid {{{user}}} -setgid {{{group}}} - -exec {{{command}}} >> {{{logs}}}/{{{application}}}/{{{process}}}-{{{number}}}.log 2>&1 diff --git a/lib/upstart/foreman-APP.conf b/lib/upstart/foreman-APP.conf deleted file mode 100644 index fc04f45..0000000 --- a/lib/upstart/foreman-APP.conf +++ /dev/null @@ -1,4 +0,0 @@ -#{{{application}}}-{{{process}}} -start on starting {{{application}}} -stop on stopping {{{application}}} - diff --git a/lib/upstart/foreman.conf b/lib/upstart/foreman.conf deleted file mode 100644 index af6572c..0000000 --- a/lib/upstart/foreman.conf +++ /dev/null @@ -1,13 +0,0 @@ -#{{{application}}} -pre-start script - -bash << "EOF" - mkdir -p {{{logs}}}/{{{application}}} - chown -R {{{user}}} {{{logs}}}/{{{application}}} -EOF - -end script - -start on runlevel [2345] - -stop on runlevel [016] diff --git a/nf.js b/nf.js deleted file mode 100755 index 6ad22a4..0000000 --- a/nf.js +++ /dev/null @@ -1,291 +0,0 @@ -#!/usr/bin/env node -// Copyright IBM Corp. 2012,2015. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var path = require('path'); -var events = require('events'); -var fs = require('fs'); -var colors = require('./lib/colors'); -var quote = require('shell-quote').quote; - -var program = require('commander'); -var display = require('./lib/console').Console; - -var nf = require('./package.json'); - -program.version(nf.version); -program.option('-j, --procfile ' ,'load procfile FILE','Procfile'); -program.option('-e, --env ' ,'load environment from FILE, a comma-separated list','.env'); -program.option('-p, --port ' ,'start indexing ports at number PORT',0); - - -// Foreman Event Bus/Emitter // - -var emitter = new events.EventEmitter(); -emitter.once('killall',function(signal){ - display.Done("Killing all processes with signal ", signal); -}); -emitter.setMaxListeners(50); - -var _proc = require('./lib/proc'); -var start = _proc.start; -var once = _proc.once; - -var _procfile = require('./lib/procfile'); -var loadProc = _procfile.loadProc; - -var _envs = require('./lib/envs'); -var loadEnvs = _envs.loadEnvs; - -var _requirements = require('./lib/requirements'); -var getreqs = _requirements.getreqs; -var calculatePadding = _requirements.calculatePadding; - -var startProxies = require('./lib/proxy').startProxies; -var startForward = require('./lib/forward').startForward; - -// Kill All Child Processes on SIGINT -process.once('SIGINT', function() { - display.Warn('Interrupted by User'); - emitter.emit('killall', 'SIGINT'); -}); - -program - .command('start [procs]') - .usage('[Options] [Processes] e.g. web=1,log=2,api') - .option('-s, --showenvs' ,'show ENV variables on start',false) - .option('-x, --proxy ' ,'start a load balancing proxy on PORT') - .option('--ssl-key ' ,'a key file to use when proxying SSL') - .option('--ssl-cert ','a cert file to use when proxying SSL') - .option('-f, --forward ' ,'start a forward proxy on PORT') - .option('-i, --intercept ' ,'set forward proxy to intercept HOSTNAME',null) - .option('-r, --raw' ,'raw log output with no app name, timestamp, wrap or trim', false) - .option('-t, --trim ' ,'trim logs to N characters',0) - .option('-w, --wrap' ,'wrap logs (negates trim)') - .description('Start the jobs in the Procfile') - .action(function(args) { - - var command = this; - - var envs = loadEnvs(program.env); - - var proc = loadProc(program.procfile); - - if(!proc) { return; } - - if(command.showenvs){ - for(var key in envs){ - display.Alert("env %s=%s", key, envs[key]); - } - } - - var reqs = getreqs(args, proc); - - display.padding = calculatePadding(reqs); - - display.raw = command.raw; - - if(command.wrap) { - display.wrapline = process.stdout.columns - display.padding - 7; - display.trimline = 0; - display.Alert('Wrapping display Output to %d Columns', display.wrapline); - } else { - display.trimline = command.trim; - if(display.trimline > 0){ - display.Alert('Trimming display Output to %d Columns', display.trimline); - } - } - - if(command.forward) { - startForward(command.forward, command.intercept, emitter); - } - - startProxies(reqs, proc, command, emitter, program.port || envs.PORT || process.env.PORT || 5000); - - start(proc, reqs, envs, program.port || envs.PORT || process.env.PORT || 5000, emitter); - }); - -program - .command('run ') - .usage('[Options]') - .option('-s, --showenvs', 'show ENV variables on start', false) - .description('Run a one off process using the ENV variables') - .action(function(args) { - - var command = this; - - var envs = loadEnvs(program.env); - - var callback = function(code) { - process.exit(code); - }; - - if(!args || !args.length) { return; } - - var input = quote(args); - - if(command.showenvs) { - for(var key in envs){ - display.Alert("env %s=%s",key,envs[key]); - } - } - - display.trimline = process.stdout.columns - 5; - - once(input, envs, callback); - }); - -var exporters = require('./lib/exporters'); - -program - .command('export [PROCS]') - .option('-a, --app ' ,'export upstart application as NAME','foreman') - .option('-u, --user ' ,'export upstart user as NAME','root') - .option('-o, --out ' ,'export upstart files to DIR','.') - .option('-c, --cwd ' ,'change current working directory to DIR') - .option('-g, --gid ' ,'set gid of upstart config to GID') - .option('-l, --log ' ,'specify upstart log directory','/var/log') - .option('-t, --type ' ,'export file to TYPE (default upstart)','upstart') - .option('-m, --template ' ,'use template folder') - .description('Export to an upstart job independent of foreman') - .action(function(procArgs) { - - var command = this; - - var envs = loadEnvs(program.env); - - var procs = loadProc(program.procfile); - - if(!procs) { return; } - - var req = getreqs(procArgs, procs); - - // Variables for Upstart Template - var config = { - application : command.app, - cwd : path.resolve(process.cwd(), command.cwd || ''), - user : command.user, - logs : command.log, - envs : envs, - group : command.gid || command.user, - template : command.template - }; - - config.envfile = path.resolve(program.env); - - var writeout; - if(exporters[command.type]) { - writeout = exporters[command.type]; - } else { - display.Error("Unknown Export Format", command.type); - process.exit(1); - } - - // Check for Upstart User - // friendly warning - does not stop export - var userExists = false; - fs.readFileSync('/etc/passwd') - .toString().split(/\n/).forEach(function(line) { - if(line.match(/^[^:]*/)[0] == config.user){ - userExists = true; - } - }); - - if(!userExists) { - display.Warn(display.fmt("User %s Does Not Exist on System", config.user)); - } - - var baseport = parseInt(program.port || envs.PORT || process.env.PORT || 5000); - var baseport_i = 0; - var baseport_j = 0; - var envl = []; - - config.processes = []; - - // This is ugly because of shitty support for array copying - // Cleanup is definitely required - for(var key in req) { - - var c = {}; - var cmd = procs[key]; - - if (!cmd){ - display.Warn("Required Key '%s' Does Not Exist in Procfile Definition", key); - continue; - } - - var n = req[key]; - - config.processes.push({process:key, n: n}); - c.process = key; - c.command = cmd; - - for(var _ in config){ - c[_] = config[_]; - } - - c.numbers = []; - for(var i=1; i <= n; i++) { - - var conf = {}; - conf.number = i; - - for(_ in c){ - conf[_] = c[_]; - } - - conf.port = baseport + baseport_i + baseport_j * 100; - - envl = []; - for(key in envs) { - envl.push({ - key: key, - value: envs[key] - }); - } - envl.push({ key: 'PORT', value: conf.port }); - envl.push({ key: 'FOREMAN_WORKER_NAME', value: conf.process + '.' + conf.number }); - - conf.envs = envl; - - // Write the APP-PROCESS-N.conf File - writeout.foreman_app_n(conf,command.out); - - baseport_i++; - c.numbers.push({number: i}); - } - - envl = []; - for(key in envs){ - envl.push({ - key: key, - value: envs[key] - }); - } - - c.envs = envl; - - // Write the APP-Process.conf File - writeout.foreman_app(c,command.out); - - baseport_i = 0; - baseport_j++; - } - - // Write the APP.conf File - writeout.foreman(config,command.out); - - }); - -program.parse(process.argv); - -if (!process.argv.slice(2).length) { - console.log(colors.cyan(' _____ ')); - console.log(colors.cyan(' | __|___ ___ ___ _____ ___ ___ ')); - console.log(colors.yellow(' | __| . | _| -_| | | |')); - console.log(colors.magenta(' |__| |___|_| |___|_|_|_|_^_|_|_|')); - program.outputHelp(); - process.exit(1); -} diff --git a/package.json b/package.json deleted file mode 100644 index 5028906..0000000 --- a/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "foreman", - "version": "3.0.1", - "homepage": "http://strongloop.github.io/node-foreman/", - "description": "Node Implementation of Foreman", - "author": "StrongLoop, Inc.", - "license": "MIT", - "keywords": [ - "foreman", - "upstart", - "commandline", - "env", - "Procfile" - ], - "bin": { - "nf": "nf.js" - }, - "files": [ - "forward.js", - "nf.js", - "proxy.js", - "lib/" - ], - "scripts": { - "pretest": "jshint .", - "test": "tap test/*.test.*" - }, - "dependencies": { - "commander": "^2.15.1", - "http-proxy": "^1.17.0", - "mustache": "^2.2.1", - "shell-quote": "^1.6.1" - }, - "repository": { - "type": "git", - "url": "https://github.com/strongloop/node-foreman.git" - }, - "bugs": { - "url": "https://github.com/strongloop/node-foreman/issues", - "email": "callback@strongloop.com" - }, - "engines": { - "node": ">=6" - }, - "preferGlobal": true, - "devDependencies": { - "chai": "~1.9.1", - "jshint": "^2.6.3", - "rimraf": "~2.2.8", - "tap": "^0.7.1" - } -} diff --git a/params.json b/params.json new file mode 100644 index 0000000..65bd30e --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"node-foreman","tagline":"A Node.js Version of Foreman","body":"# Node Foreman [![Build Status](https://travis-ci.org/strongloop/node-foreman.svg)](https://travis-ci.org/strongloop/node-foreman)\r\n\r\nNode Foreman is a Node.js version of the popular\r\n[Foreman](http://ddollar.github.com/foreman/) tool,\r\nwith a few Node specific changes.\r\n\r\n> Foreman is a manager for Procfile-based applications.\r\n> Its aim is to abstract away the details of the Procfile\r\n> format, and allow you to either run your application\r\n> directly or export it to some other process management format.\r\n\r\n## Install\r\n\r\nInstall the command line tool\r\n\r\n $ npm install -g foreman\r\n\r\n## Deviations from the original Foreman\r\n\r\n * Each worker has an additional automatic environment variable,\r\n `FOREMAN_WORKER_NAME`, that contains the the process name and worker number.\r\n * example: `web.1`, `worker.1`\r\n\r\n### How to Contribute\r\n\r\nI encourage anyone and everyone to help.\r\nIf you have a specific change in mind, open an issue; we can talk about it there.\r\n\r\nIf you would like to make a code change, go ahead.\r\nFork the repository, open a pull request.\r\nDo this early, and talk about the change you want to make.\r\nMaybe we can work together on it.\r\n\r\nRefactor Refactor Refactor!\r\nYou are free to add features, or just help clean things up.\r\n\r\n## Usage\r\n\r\nNode Foreman can be run with as little as `nf start`, as long as `npm start` has been defined.\r\nFor more complicated applications you will want to define a `Procfile` for your various server\r\nprocesses and and a `.env` file to preload environmental variables.\r\n\r\nYour module directory should end up looking like the following:\r\n\r\n![List Foreman Directory](https://raw.github.com/strongloop/node-foreman/master/assets/foreman-ls.png)\r\n\r\nOnce your Procfile is defined, run your application with `nf start`:\r\n\r\n![Start Foreman](https://raw.github.com/strongloop/node-foreman/master/assets/foreman-start.png)\r\n\r\nNode Foreman _always_ starts in the foreground and expects your applications\r\nto do the same. If your processes exit, Node Foreman will assume an error\r\nhas ocurred and shut your application down.\r\n\r\nInstead of daemonizing, you should use `nf export` to ready your application\r\nfor production.\r\n\r\nFor more information try any of the following:\r\n\r\n\t$ nf --help\r\n\t$ nf start --help\r\n\t$ nf export --help\r\n\r\n### Procfile\r\n\r\nThe `Procfile` format is a simple `key : command` format:\r\n\r\n web: node web_server.js\r\n api: node api_server.js\r\n log: node log_server.js\r\n\r\nEach line should contain a separate process.\r\n\r\n### Environmental Variables\r\n\r\nCreate a `.env` file to pre-load environmental variables with the format:\r\n\r\n MYSQL_NAME=superman\r\n MYSQL_PASS=cryptonite\r\n\r\nThe equivalent `.env` file may alternatively be a valid JSON document:\r\n\r\n {\r\n \"mysql\":{\r\n \"name\": \"superman\",\r\n \"pass\": \"cryptonite\"\r\n }\r\n }\r\n\r\nThe above JSON document will be flattened into env variables by\r\nconcatenating the nested values with an underscore.\r\nEnvironmental variables are passed in fully capitalized.\r\n\r\n {\r\n \"mysql\":{\r\n \"name\": \"superman\", # => MYSQL_NAME=superman\r\n \"pass\": \"cryptonite\" # => MYSQL_PASS=cryptonite\r\n }\r\n }\r\n\r\nThere is no need to specify which type of file you wish to use.\r\n\r\n#### The PATH environment variable\r\n\r\nThe `PATH` variable is given special treament and is always read\r\nfrom the environment that the `nf` command has been executed from,\r\nrather than a `.env` file. To set a different `PATH` execute\r\n`nf` with the `PATH` variable set appropriately.\r\n\r\n```bash\r\nPATH=/opt/foo:/opt/bar:$PATH nf export\r\n```\r\n\r\n#### Best Practices\r\n\r\nGenerally you should not check your `.env` file into version control.\r\nThe `.env` file contain _only_ parameters that depend on where the application\r\ngets deployed. It should not contain anything related to _how_ the application\r\nis deployed.\r\n\r\nFor example, good candidates for the `.env` file are MySQL connection information,\r\nport bindings, and other passwords.\r\n\r\n### Advanced Usage\r\n\r\nNode Foreman lets you start multiple jobs of the same type:\r\n\r\n $ nf start web=5\r\n\r\n 18:51:12: web.1 | Web Server started listening on 0.0.0.0:5000\r\n 18:51:12: web.2 | Web Server started listening on 0.0.0.0:5001\r\n 18:51:12: web.3 | Web Server started listening on 0.0.0.0:5002\r\n 18:51:12: web.4 | Web Server started listening on 0.0.0.0:5003\r\n 18:51:12: web.5 | Web Server started listening on 0.0.0.0:5004\r\n\r\nEach job will be started as its own process, receiving a different `PORT`\r\nenvironmental variable.\r\nThe port number for processes of the same type will be offset by 1.\r\nThe port number for processes of different types will be offset by 100.\r\n\r\n $ nf start web=2,api=2\r\n\r\n 18:51:12: web.1 | Web Server started listening on 0.0.0.0:5000\r\n 18:51:12: web.2 | Web Server started listening on 0.0.0.0:5001\r\n 18:51:12: api.1 | Api Server started listening on 0.0.0.0:5100\r\n 18:51:12: api.2 | Api Server started listening on 0.0.0.0:5101\r\n\r\n## Export to Production\r\n\r\nNode Foreman is designed to be in a development environment,\r\nhowever it can export an Upstart job for use in production.\r\nThe Upstart file has _no_ dependency on Node Foreman.\r\n\r\n $ nf export\r\n Loaded ENV .env File as JSON Format\r\n Wrote : ./foreman-web-1.conf\r\n Wrote : ./foreman-web.conf\r\n Wrote : ./foreman-api-1.conf\r\n Wrote : ./foreman-api.conf\r\n Wrote : ./foreman-log-1.conf\r\n Wrote : ./foreman-log.conf\r\n Wrote : ./foreman.conf\r\n\r\nYou can inspect your upstart files before placing them in the right\r\ndirectory, or have foreman do it for you:\r\n\r\n $ sudo nf export -o /etc/init\r\n Loaded ENV .env File as JSON Format\r\n Wrote : /etc/init/foreman-api-1.conf\r\n Wrote : /etc/init/foreman-web.conf\r\n Wrote : /etc/init/foreman-api.conf\r\n Wrote : /etc/init/foreman-log.conf\r\n Wrote : /etc/init/foreman-log-1.conf\r\n Wrote : /etc/init/foreman-web-1.conf\r\n Wrote : /etc/init/foreman.conf\r\n\r\nStart and stop your jobs with\r\n\r\n $ sudo start foreman\r\n $ sudo stop foreman\r\n\r\nThe export will occur with whatever environmental variables are\r\nlisted in the .env file.\r\n\r\n### Systemd Support\r\n\r\n_This section is beta_\r\n\r\nOptionally specify a type `-t systemd` during export for [systemd](http://www.freedesktop.org/wiki/Software/systemd) support.\r\n\r\n### Supervisord Support\r\n\r\nYou can also use a type `-t supervisord` during export for [supervisord](http://www.supervisord.org) support.\r\n\r\nThis will generate a `APP.conf` file grouping the application processes and a `APP-PROCESS-N.conf` file for each process.\r\n\r\n $ nf export --type supervisord\r\n Loaded ENV .env File as JSON Format\r\n Wrote : ./foreman-web-1.conf\r\n Wrote : ./foreman-api-1.conf\r\n Wrote : ./foreman-log-1.conf\r\n Wrote : ./foreman.conf\r\n\r\nYou can start / stop / restart individual processes.\r\n\r\n $ sudo supervisorctl start 'foreman:foreman-web-1'\r\n $ sudo supervisorctl stop 'foreman:foreman-web-1'\r\n $ sudo supervisorctl restart 'foreman:foreman-web-1'\r\n\r\nOr the entire group of processes\r\n\r\n $ sudo supervisorctl start 'foreman:*'\r\n $ sudo supervisorctl stop 'foreman:*'\r\n $ sudo supervisorctl restart 'foreman:*'\r\n\r\n### Advanced Exports\r\n\r\nYou can specify the type and number of processes exported using\r\nthe `type=num` syntax:\r\n\r\n $ nf export web=2,api=2\r\n\r\nUse `-u ` to have the exported job run as `USER`.\r\nNote that if you need to bind to privileged ports, you _must_\r\nstart as `root`. In such a case, we advise you to drop user\r\npermissions after binding.\r\n\r\nIf you want to call your upstart job something other than foreman,\r\nuse `-a ` and manage your jobs with `sudo start `.\r\n\r\n## Reverse Proxy\r\n\r\nNode.js processes are supposed to be stateless.\r\nApplication scale by starting multiple processes that either share a socket,\r\nor sit behind a load balancer.\r\nNode Foreman can help you test the parallel capabilities of your application\r\nby spawning multiple processes behind a round-robin proxy automatically.\r\n\r\n\t$ nf start -x 8888 web=5\r\n\t[OKAY] Starting Proxy Server 8888 -> 5000-5004\r\n\r\nAccess your application from port `8888` and the connections will be balanced\r\nacross the servers started from ports `5000` - `5004`.\r\n\r\nIf your application gets its port number from `process.env.PORT` the proxy\r\nsetup will ocurr automatically.\r\n\r\n### Multiple Reverse Proxies\r\n\r\nIf you have multiple processes in your `Procfile` you can start multiple proxies.\r\n\r\n $ nf start -x 8888,8080,9090\r\n\r\nThis will start 3 separate proxies and bind each to a separate process group.\r\nProxies are bound based on their order specified, their order in the Procfile,\r\nor by their order on the command line.\r\n\r\n $ nf start -x 8888,9999 web,api\r\n\r\n### Privileged Ports\r\n\r\nNode Foreman disallows applications from starting on privileged ports.\r\nIt does however allow proxies to be bound to lower ports, such as port 80.\r\n\r\nIf you require access to a privileged port, start Node Foreman with `sudo`:\r\n\r\n\t$ sudo nf start -x 80 web=5\r\n\t[OKAY] Starting Proxy Server 80 -> 5000-5004\r\n\r\nYour application will then be accessible via port 80.\r\n\r\nYour applications will _still_ be started in user space, and the proxy will\r\ndrop its privileges after binding to the privileged port.\r\n\r\n## Forward Proxy\r\n\r\nLocal development and testing has huge advantages,\r\nbut sometimes one needs to test web applications agains their real-world domain name.\r\nEditing `/etc/hosts` is a pain however, and error prone.\r\n\r\nNode Foreman can start up an HTTP forward proxy which your browser can route requests through.\r\nThe forward proxy will intercept requests based on domain name, and route them to the local application.\r\n\r\n $ nf start -f 9999 -h nodefly.com\r\n [OKAY] Forward Proxy Started in Port 9999\r\n [OKAY] Intercepting requests to nodefly.com through forward proxy\r\n\r\nA forward proxy is useful when testing OAuth, or other external services with application callbacks.\r\n\r\nFor users with Google Chrome, this can be paired with [Proxy Switch Sharp](http://switchy.samabox.com/) for great results.\r\n","google":"UA-37775386-1","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/proxy.js b/proxy.js deleted file mode 100644 index 98e037d..0000000 --- a/proxy.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright IBM Corp. 2012,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var fs = require('fs'); -var http = require('http'); -var https = require('https'); -var htproxy = require('http-proxy'); - -var port = parseInt(process.env.PORT); - -var upstream_host = process.env.UPSTREAM_HOST; -var upstream_port = parseInt(process.env.UPSTREAM_PORT); -var upstream_size = parseInt(process.env.UPSTREAM_SIZE); -var sslCert = process.env.SSL_CERT; -var sslKey = process.env.SSL_KEY; -var sslPort = parseInt(process.env.SSL_PORT); - -var addresses = []; -for(var i = 0; i < upstream_size; i++) { - addresses.push({ - host: upstream_host, - port: upstream_port + i, - protocol: 'http', - }); -} - -// Proxy -var proxy = htproxy.createProxyServer({ - // Set the x-forwarded- headers, because apps often need them to make - // decisions (such as about redirecting to SSL or a canonical host), - // and proxies often do this for you in the real world. - xfwd: true -}); - -// Hanle Error -proxy.on('error',function(err,req,res){ - console.error("Proxy Error: ",err); - res.writeHead(500); - res.write("Upstream Proxy Error"); - res.end(); -}); - -// Main HTTP Server -http.createServer(function (req, res) { - - var target = addresses.shift(); - - proxy.web(req, res, {target: target}); - - addresses.push(target); - -}).listen(port, function() { - process.send({http: this.address().port}); -}); - -if (sslCert && sslKey) { - https.createServer({ - key: fs.readFileSync(sslKey), - cert: fs.readFileSync(sslCert) - }, - function (req, res) { - - var target = addresses.shift(); - - proxy.web(req, res, {target: target}); - - addresses.push(target); - - }).listen(sslPort, function() { - process.send({https: this.address().port}); - }); -} diff --git a/stylesheets/ie.css b/stylesheets/ie.css new file mode 100644 index 0000000..43882f2 --- /dev/null +++ b/stylesheets/ie.css @@ -0,0 +1,3 @@ +nav { + display: none; +} diff --git a/stylesheets/normalize.css b/stylesheets/normalize.css new file mode 100644 index 0000000..bc2ba93 --- /dev/null +++ b/stylesheets/normalize.css @@ -0,0 +1,459 @@ +/* normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */ +/* ============================================================================= + HTML5 display definitions + ========================================================================== */ +/* + * Corrects block display not defined in IE6/7/8/9 & FF3 + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects inline-block display not defined in IE6/7/8/9 & FF3 + */ +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying 'audio' without controls + */ +audio:not([controls]) { + display: none; +} + +/* + * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 + * Known issue: no IE6 support + */ +[hidden] { + display: none; +} + +/* ============================================================================= + Base + ========================================================================== */ +/* + * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units + * http://clagnut.com/blog/348/#c790 + * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom + * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ + */ +html { + font-size: 100%; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -ms-text-size-adjust: 100%; + /* 2 */ +} + +/* + * Addresses font-family inconsistency between 'textarea' and other form elements. + */ +html, +button, +input, +select, +textarea { + font-family: sans-serif; +} + +/* + * Addresses margins handled incorrectly in IE6/7 + */ +body { + margin: 0; +} + +/* ============================================================================= + Links + ========================================================================== */ +/* + * Addresses outline displayed oddly in Chrome + */ +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers + * people.opera.com/patrickl/experiments/keyboard/test + */ +a:hover, +a:active { + outline: 0; +} + +/* ============================================================================= + Typography + ========================================================================== */ +/* + * Addresses font sizes and margins set differently in IE6/7 + * Addresses font sizes within 'section' and 'article' in FF4+, Chrome, S5 + */ +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.75em; + margin: 2.33em 0; +} + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome + */ +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to 'bolder' in FF3+, S4/5, Chrome +*/ +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome + */ +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9 + */ +mark { + background: #ff0; + color: #000; +} + +/* + * Addresses margins set differently in IE6/7 + */ +p, +pre { + margin: 1em 0; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ +pre, +code, +kbd, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * 1. Addresses CSS quotes not supported in IE6/7 + * 2. Addresses quote property not supported in S4 + */ +/* 1 */ +q { + quotes: none; +} + +/* 2 */ +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents sub and sup affecting line-height in all browsers + * gist.github.com/413930 + */ +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ============================================================================= + Lists + ========================================================================== */ +/* + * Addresses margins set differently in IE6/7 + */ +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +/* + * Addresses paddings set differently in IE6/7 + */ +menu, +ol, +ul { + padding: 0 0 0 40px; +} + +/* + * Corrects list images handled incorrectly in IE7 + */ +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + +/* ============================================================================= + Embedded content + ========================================================================== */ +/* + * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 + * 2. Improves image quality when scaled in IE7 + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ +img { + border: 0; + /* 1 */ + -ms-interpolation-mode: bicubic; + /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9 + */ +svg:not(:root) { + overflow: hidden; +} + +/* ============================================================================= + Figures + ========================================================================== */ +/* + * Addresses margin not present in IE6/7/8/9, S5, O11 + */ +figure { + margin: 0; +} + +/* ============================================================================= + Forms + ========================================================================== */ +/* + * Corrects margin displayed oddly in IE6/7 + */ +form { + margin: 0; +} + +/* + * Define consistent border, margin, and padding + */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9 + * 2. Corrects text not wrapping in FF3 + * 3. Corrects alignment displayed oddly in IE6/7 + */ +legend { + border: 0; + /* 1 */ + padding: 0; + white-space: normal; + /* 2 */ + *margin-left: -7px; + /* 3 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers + * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome + * 3. Improves appearance and consistency in all browsers + */ +button, +input, +select, +textarea { + font-size: 100%; + /* 1 */ + margin: 0; + /* 2 */ + vertical-align: baseline; + /* 3 */ + *vertical-align: middle; + /* 3 */ +} + +/* + * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet + */ +button, +input { + line-height: normal; + /* 1 */ +} + +/* + * 1. Improves usability and consistency of cursor style between image-type 'input' and others + * 2. Corrects inability to style clickable 'input' types in iOS + * 3. Removes inner spacing in IE7 without affecting normal text inputs + * Known issue: inner spacing remains in IE6 + */ +button, +input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + /* 1 */ + -webkit-appearance: button; + /* 2 */ + *overflow: visible; + /* 3 */ +} + +/* + * Re-set default cursor for disabled elements + */ +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9 + * 2. Removes excess padding in IE8/9 + * 3. Removes excess padding in IE7 + Known issue: excess padding remains in IE6 + */ +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + /* 1 */ + padding: 0; + /* 2 */ + *height: 13px; + /* 3 */ + *width: 13px; + /* 3 */ +} + +/* + * 1. Addresses appearance set to searchfield in S5, Chrome + * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) + */ +input[type="search"] { + -webkit-appearance: textfield; + /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in S5, Chrome on OS X + */ +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in FF3+ + * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ + */ +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9 + * 2. Improves readability and alignment in all browsers + */ +textarea { + overflow: auto; + /* 1 */ + vertical-align: top; + /* 2 */ +} + +/* ============================================================================= + Tables + ========================================================================== */ +/* + * Remove most spacing between table cells + */ +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..c6a6452 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,69 @@ +.highlight { background: #ffffff; } +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #000080 } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/styles.css b/stylesheets/styles.css new file mode 100644 index 0000000..dacf2e1 --- /dev/null +++ b/stylesheets/styles.css @@ -0,0 +1,255 @@ +@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700); + +body { + padding:50px; + font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; + color:#777; + font-weight:300; +} + +h1, h2, h3, h4, h5, h6 { + color:#222; + margin:0 0 20px; +} + +p, ul, ol, table, pre, dl { + margin:0 0 20px; +} + +h1, h2, h3 { + line-height:1.1; +} + +h1 { + font-size:28px; +} + +h2 { + color:#393939; +} + +h3, h4, h5, h6 { + color:#494949; +} + +a { + color:#39c; + font-weight:400; + text-decoration:none; +} + +a small { + font-size:11px; + color:#777; + margin-top:-0.6em; + display:block; +} + +.wrapper { + width:860px; + margin:0 auto; +} + +blockquote { + border-left:1px solid #e5e5e5; + margin:0; + padding:0 0 0 20px; + font-style:italic; +} + +code, pre { + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + color:#333; + font-size:12px; +} + +pre { + padding:8px 15px; + background: #f8f8f8; + border-radius:5px; + border:1px solid #e5e5e5; + overflow-x: auto; +} + +table { + width:100%; + border-collapse:collapse; +} + +th, td { + text-align:left; + padding:5px 10px; + border-bottom:1px solid #e5e5e5; +} + +dt { + color:#444; + font-weight:700; +} + +th { + color:#444; +} + +img { + max-width:100%; +} + +header { + width:270px; + float:left; + position:fixed; +} + +header ul { + list-style:none; + height:40px; + + padding:0; + + background: #eee; + background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); + background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + + border-radius:5px; + border:1px solid #d2d2d2; + box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; + width:270px; +} + +header li { + width:89px; + float:left; + border-right:1px solid #d2d2d2; + height:40px; +} + +header ul a { + line-height:1; + font-size:11px; + color:#999; + display:block; + text-align:center; + padding-top:6px; + height:40px; +} + +strong { + color:#222; + font-weight:700; +} + +header ul li + li { + width:88px; + border-left:1px solid #fff; +} + +header ul li + li + li { + border-right:none; + width:89px; +} + +header ul a strong { + font-size:14px; + display:block; + color:#222; +} + +section { + width:500px; + float:right; + padding-bottom:50px; +} + +small { + font-size:11px; +} + +hr { + border:0; + background:#e5e5e5; + height:1px; + margin:0 0 20px; +} + +footer { + width:270px; + float:left; + position:fixed; + bottom:50px; +} + +@media print, screen and (max-width: 960px) { + + div.wrapper { + width:auto; + margin:0; + } + + header, section, footer { + float:none; + position:static; + width:auto; + } + + header { + padding-right:320px; + } + + section { + border:1px solid #e5e5e5; + border-width:1px 0; + padding:20px 0; + margin:0 0 20px; + } + + header a small { + display:inline; + } + + header ul { + position:absolute; + right:50px; + top:52px; + } +} + +@media print, screen and (max-width: 720px) { + body { + word-wrap:break-word; + } + + header { + padding:0; + } + + header ul, header p.view { + position:static; + } + + pre, code { + word-wrap:normal; + } +} + +@media print, screen and (max-width: 480px) { + body { + padding:15px; + } + + header ul { + display:none; + } +} + +@media print { + body { + padding:0.4in; + font-size:12pt; + color:#444; + } +} diff --git a/test/console-output.test.js b/test/console-output.test.js deleted file mode 100644 index 2ce9f46..0000000 --- a/test/console-output.test.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('chai').assert; -var util = require('util'); -var Console = require('../lib/console'); - -var logs = { log: [], warn: [], error: [] }; -var logger = { - log: makeLogger(logs.log), - warn: makeLogger(logs.warn), - error: makeLogger(logs.error) -}; - -var c = new Console(logger); -resetLogs(); - -assert.equal(logs.log.length, 0); -assert.equal(logs.warn.length, 0); -assert.equal(logs.error.length, 0); - -resetLogs(); -c.Alert('ze message'); -assertLogged('log', /\[OKAY\]/); -assertLogged('log', /ze message/); - -resetLogs(); -c.Done('ze message'); -assertLogged('log', /\[DONE\]/); -assertLogged('log', /ze message/); - -resetLogs(); -c.Warn('ze warning'); -assertLogged('warn', /\[WARN\]/); -assertLogged('warn', /ze warning/); - -resetLogs(); -c.Error('such an error'); -assertLogged('error', /\[FAIL\]/); -assertLogged('error', /such an error/); - -resetLogs(); -c.raw = true; -c.log('a key', null, 'a log message'); -assertLogged('log', /^a log message$/); -c.raw = false; - -assert.lengthOf(c.trim('a very long string this is!', 5), 6); - -function makeLogger(collector) { - return function() { - collector.push(util.format.apply(util, arguments)); - }; -} - -function resetLogs() { - logs.log.splice(0, logs.log.length); - logs.warn.splice(0, logs.warn.length); - logs.error.splice(0, logs.error.length); -} - -function assertLogged(logName, pattern) { - var actual = logs[logName][logs[logName].length - 1]; - - Object.keys(logs).forEach(function (log) { - assert.lengthOf(logs[log], logName === log ? 1 : 0); - }); - - assert.match(actual, pattern); -} diff --git a/test/console-trim.test.js b/test/console-trim.test.js deleted file mode 100644 index 191973d..0000000 --- a/test/console-trim.test.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// Needed before requiring colors, otherwise its colorizers are no-ops. -process.stdout.isTTY = true; - -var assert = require('chai').assert; -var Console = require('../lib/console').Console; -var colors = require('../lib/colors'); - -var red = colors.red('red'); -var blue = colors.blue('blue'); - -var long = 'Roses are red, Violets are blue, this string is long, and should be trimmed, too!'; -var colorLong = long.replace('red', red).replace('blue', blue); - -assert.lengthOf(long, 81); -assert.lengthOf(colorLong, 99); -assert.equal(Console.trim(colorLong, 50), Console.trim(long, 50)); - -assert.equal(Console.trim(colorLong, long.length), colorLong, - 'trim() should leave colors intact if no trimming is performed'); - -var indented = ' indented'; -assert.equal(Console.trim(indented, 100), indented, - 'trim() should always preserve leading whitespace'); -var padded = ' padded '; -var trimmed = ' padded'; -assert.equal(Console.trim(padded, 100), trimmed, - 'trim() should always trim trailing whitespace'); diff --git a/test/envs-commented.test.js b/test/envs-commented.test.js deleted file mode 100644 index 7257a07..0000000 --- a/test/envs-commented.test.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var envs = require('../lib/envs'); - -var input = '### This is a config file...\n' + - ' \n' + - '# Very important setting!\n' + - 'setting = important\n' + - ' \n' + - '# Dangerous, we should commend this out: \n' + - '# DANGER = HIGH VOLTAGE \n' + - ' \n' + - '# end \n'; - -var expected = 'setting=important\n'; - -var loadedEnv = envs.keyValue(input); -var dumpedEnv = envs.dumpEnv(loadedEnv); -var loadedFlat = envs.keyValue(expected); -var dumpedFlat = envs.dumpEnv(loadedFlat); -assert.equal(dumpedEnv, expected); -assert.equal(dumpedFlat, expected); diff --git a/test/envs-empty.test.js b/test/envs-empty.test.js deleted file mode 100644 index 61a302a..0000000 --- a/test/envs-empty.test.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var envs = require('../lib/envs'); - -var emptyEnvs = ['', '\n', ' \n \n \n']; - -emptyEnvs.forEach(function (env) { - var loaded = envs.keyValue(env); - // {} == {} - assert.equal(Object.keys(loaded).length, 0); -}); - -assert.equal(envs.dumpEnv({}), '\n'); diff --git a/test/envs-json.test.js b/test/envs-json.test.js deleted file mode 100644 index b6ba462..0000000 --- a/test/envs-json.test.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var envs = require('../lib/envs'); - -var json = { - "top": { - "middle": { - "bottom": "value" - }, - "other": [ "zero", "one", "two" ] - }, - "last": 42 -}; -var flattened = { - 'LAST': 42, - 'TOP_MIDDLE_BOTTOM': 'value', - 'TOP_OTHER_0': 'zero', - 'TOP_OTHER_1': 'one', - 'TOP_OTHER_2': 'two', -}; - -var dumped = [ - 'LAST=42', - 'TOP_MIDDLE_BOTTOM=value', - 'TOP_OTHER_0=zero', - 'TOP_OTHER_1=one', - 'TOP_OTHER_2=two', -].join('\n') + '\n'; - -assert.deepEqual(envs.flattenJSON(json), flattened); -assert.equal(envs.dumpEnv(flattened), dumped); diff --git a/test/envs-quoted.test.js b/test/envs-quoted.test.js deleted file mode 100644 index 865e1cb..0000000 --- a/test/envs-quoted.test.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var envs = require('../lib/envs'); - -var parsedHash = envs.keyValue( - '#commented heading. \n' + - 'key = "quoted#hash" \n' + - 'key2 = stripped#comment \n' + - 'key3 = base64=== \n' -); - -assert.equal(parsedHash.key, 'quoted#hash'); -assert.equal(parsedHash.key2, 'stripped'); -assert.equal(parsedHash.key3, 'base64==='); diff --git a/test/exit-with-code-gracefully.test.sh b/test/exit-with-code-gracefully.test.sh deleted file mode 100755 index f2e757d..0000000 --- a/test/exit-with-code-gracefully.test.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" - -rm -rf sandbox -mkdir -p sandbox - -# We'll exit with a code that cannot be used as a signal. This exposes a -# potential bug in termination handling. -printf "exitwithcode: sleep 0.1; exit 132" > sandbox/Procfile -node ../nf.js --procfile sandbox/Procfile start >sandbox/signals.txt 2>&1 && exit 0 - -exit 1 - diff --git a/test/export-custom-absolute.test.sh b/test/export-custom-absolute.test.sh deleted file mode 100755 index 0705404..0000000 --- a/test/export-custom-absolute.test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -PATH=$(dirname $(which node)) $NF export \ - --app upstart-test --user test-user \ - --out sandbox --type upstart \ - --template $(pwd)/fixtures/upstart-custom-templates \ - --env fixtures/env.env --procfile fixtures/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -# Fixtures can be updated to match output by running `npm test --update-fixtures` -test -n "$npm_config_update_fixtures" && cp sandbox/* fixtures/upstart-custom/ - -diff -r -u fixtures/upstart-custom sandbox 1>&2 || exit $? diff --git a/test/export-custom-relative.test.sh b/test/export-custom-relative.test.sh deleted file mode 100755 index 963e109..0000000 --- a/test/export-custom-relative.test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -PATH=$(dirname $(which node)) $NF export \ - --app upstart-test --user test-user \ - --out sandbox --type upstart \ - --template fixtures/upstart-custom-templates \ - --env fixtures/env.env --procfile fixtures/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -# Fixtures can be updated to match output by running `npm test --update-fixtures` -test -n "$npm_config_update_fixtures" && cp sandbox/* fixtures/upstart-custom/ - -diff -r -u fixtures/upstart-custom sandbox 1>&2 || exit $? diff --git a/test/export-path-default.test.sh b/test/export-path-default.test.sh deleted file mode 100755 index 3e5bd4d..0000000 --- a/test/export-path-default.test.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" - -rm -rf sandbox -mkdir -p sandbox - -echo "PATH=something-totally-bogus" > sandbox/.env -echo "web: node app.js" > sandbox/Procfile - -node ../nf.js export --out sandbox --type upstart-single \ - --env sandbox/.env --procfile sandbox/Procfile - -grep 'env PATH="something-totally-bogus"' sandbox/foreman-web.conf || exit $? diff --git a/test/export-supervisord.test.sh b/test/export-supervisord.test.sh deleted file mode 100755 index d875013..0000000 --- a/test/export-supervisord.test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -PATH=$(dirname $(which node)) $NF export \ - --app supervisord-test --user test-user \ - --out sandbox --type supervisord \ - --env fixtures/env.env --procfile fixtures/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -diff -r -u fixtures/supervisord sandbox 1>&2 || exit $? diff --git a/test/export-systemd.test.sh b/test/export-systemd.test.sh deleted file mode 100755 index b6531a4..0000000 --- a/test/export-systemd.test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -PATH=$(dirname $(which node)) $NF export \ - --app systemd-test --user test-user \ - --out sandbox --type systemd \ - --env fixtures/env.env --procfile fixtures/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -diff -r -u fixtures/systemd sandbox 1>&2 || exit $? diff --git a/test/export-upstart-single.test.sh b/test/export-upstart-single.test.sh deleted file mode 100755 index 9e3461b..0000000 --- a/test/export-upstart-single.test.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -PATH=$(dirname $(which node)) $NF export \ - --app upstart-single-test --user test-user \ - --out sandbox --type upstart-single \ - --env fixtures/env.env --procfile fixtures/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -# Fixtures can be updated to match output by running `npm test --update-fixtures` -test -n "$npm_config_update_fixtures" && cp sandbox/* fixtures/upstart-single/ - -diff -r -u fixtures/upstart-single sandbox 1>&2 || exit $? diff --git a/test/export-upstart.test.sh b/test/export-upstart.test.sh deleted file mode 100755 index cdf89bd..0000000 --- a/test/export-upstart.test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -PATH=$(dirname $(which node)) $NF export \ - --app upstart-test --user test-user \ - --out sandbox --type upstart \ - --cwd '/EXPORT/PATH' \ - --env fixtures/env.env --procfile fixtures/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -# Fixtures can be updated to match output by running `npm test --update-fixtures` -test -n "$npm_config_update_fixtures" && cp sandbox/* fixtures/upstart/ - -diff -r -u fixtures/upstart sandbox 1>&2 || exit $? diff --git a/test/fixtures/Procfile b/test/fixtures/Procfile deleted file mode 100644 index 605c0cb..0000000 --- a/test/fixtures/Procfile +++ /dev/null @@ -1,3 +0,0 @@ -web: node server.js 5000 -api: node server.js 10000 -log: node server.js 100000 diff --git a/test/fixtures/Procfile.env b/test/fixtures/Procfile.env deleted file mode 100644 index 2bc26f9..0000000 --- a/test/fixtures/Procfile.env +++ /dev/null @@ -1,3 +0,0 @@ -env: env -env2: env -env3: env diff --git a/test/fixtures/Procfile.port b/test/fixtures/Procfile.port deleted file mode 100644 index a9e4cc6..0000000 --- a/test/fixtures/Procfile.port +++ /dev/null @@ -1,3 +0,0 @@ -app1: echo $PORT; sleep 1 -app2: echo $PORT; sleep 1 -app3: echo $PORT; sleep 1 diff --git a/test/fixtures/certs/my-server.crt.pem b/test/fixtures/certs/my-server.crt.pem deleted file mode 100644 index 9cc86cd..0000000 --- a/test/fixtures/certs/my-server.crt.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDPDCCAiQCCQDnG+u/QenSKzANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJV -UzENMAsGA1UECBMEVXRhaDEOMAwGA1UEBxMFUHJvdm8xIzAhBgNVBAoTGkFDTUUg -U2lnbmluZyBBdXRob3JpdHkgSW5jMRQwEgYDVQQDEwtleGFtcGxlLmNvbTAeFw0x -NTEwMzAyMTU2MDBaFw0xODEwMjkyMTU2MDBaMFkxCzAJBgNVBAYTAlVTMQ0wCwYD -VQQIEwRVdGFoMQ4wDAYDVQQHEwVQcm92bzEVMBMGA1UEChMMQUNNRSBTZXJ2aWNl -MRQwEgYDVQQDEwtleGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBALu/jPABX1L7rBzMXIoAqFkjiLJfVgHnFDSrgZiV6bA0J6CEPpQx279R -lWUMxcwhpEbEkWGg2j9vVJNi4iKRiF7nhir5aB8LUiooiYmRAkuTXsWlp4lq27ve -cAbF4omo2QB4AqUT6U+YwNqBt/tovdZPBjt6fiXJUeWixPKl/i9Kc38lSqD4KTww -80UCp55DT+lZYRfY5b2UGfUdr12LGYO54f3sNXAsapGlLvzWT/yg8h8cqJS2XMG5 -52ZEwv4ap33Q8x8vIchdAPmamkmV6bGZ6OaBOgIdgc/c3mcqGCKrLC0iABoLdxPx -LwCHR17myxes8IXuRovGfuRcHn5XoGECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA -fZ7EY/YA8b9cwSVyxsDb/YWgyFv6a2u54xXZ16HhQwDSMFNGvgzZTVqmWIyA5lPU -05xH+6bjJjrni+4OeTGctObQc7Ad9sv1w+NonM4LT7nMsCTecRafN2lOi2ZX8/zD -oLBP1wV9tykDXY+kPqKA/dSwPs0W2Nt7fZ/w2BpgKeib5umzmNycRflNhaoe/ywz -itJ5pIdZfF7BgisvEhgB6IYoyLoa9e7RxSYqRRXGU+YaFY3rWf8wjM3nxSEMMGWA -GeuNDFDvlZgQr7O2hYbfmciyE3AYyf4VXJttZHYNhpPRIUsif+TPypFyqm3IgCZH -SZEwl60C7zXHhHDUSTWpTg== ------END CERTIFICATE----- diff --git a/test/fixtures/certs/my-server.key.pem b/test/fixtures/certs/my-server.key.pem deleted file mode 100644 index aec3785..0000000 --- a/test/fixtures/certs/my-server.key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAu7+M8AFfUvusHMxcigCoWSOIsl9WAecUNKuBmJXpsDQnoIQ+ -lDHbv1GVZQzFzCGkRsSRYaDaP29Uk2LiIpGIXueGKvloHwtSKiiJiZECS5NexaWn -iWrbu95wBsXiiajZAHgCpRPpT5jA2oG3+2i91k8GO3p+JclR5aLE8qX+L0pzfyVK -oPgpPDDzRQKnnkNP6VlhF9jlvZQZ9R2vXYsZg7nh/ew1cCxqkaUu/NZP/KDyHxyo -lLZcwbnnZkTC/hqnfdDzHy8hyF0A+ZqaSZXpsZno5oE6Ah2Bz9zeZyoYIqssLSIA -Ggt3E/EvAIdHXubLF6zwhe5Gi8Z+5FweflegYQIDAQABAoIBAHnYIntQKLEOK/C0 -oAnfy2GuMfSw8nxhnzdfZsfD4tk7v8voh0Rd5yMOq0ndNDD6VEapI0Ccx4cLlXPh -ZKjSkhIlZ2lUW0JqcnRxwnDI7xhlF8hlbYk9FEWkYkfC/PYh4lLvj6faeDv0ApTM -Qr6ihzEiMAVBxcR4FvJU5EQlfgTpybGt5QjCy43fMtwhwK8xsK1wtf0780k6pJu/ -hJCKCH8jf/RWk1BeNlKWRukv1R9A1MtT+FtTk3IZo9yuPJ4cK0F1OAne8y9ebs+O -MzaD92JbLxCuDQm+L5/iPhCrC42b3iIN1Th7a732xTGMVgdo2vk7yGtsiNE98VNv -wa296JECgYEA+DTg5dCVUN32JAQ6GfkQfHLyhbecdiMEfu9ObVYQpIaqxsqEOMa3 -rXsHj1/VKrfpfGYemBdz6eZEHjC5MRibax+Ksyq2FTOrWFKSQ0xLBp4CnjnpDR9C -85EhSJ8UQGO7lULKzynuXfzRV+NZ8pBLlCKYfgozwgXAzDdk9+dM5PcCgYEAwaSy -9V/U9qbTixLqOw8YMuGB6/oFlnSOtCTFQ7bVDHezvkrjnof7L9RnM+aKRL3CSzQW -n7KQcCy77n0onBpEUEsbaN2VKd4LNVcwxVNMAdTn3ZAImZEAAniyTdldfdeX27Bd -pdxwkXAYF8e44NWkqYW8ZC/cAYPvY1xsuy2RR2cCgYBBgDrlixEMgTbmtFLc7dSC -8xa7YQQiTQVvthl9UxwbPwqsYV9ZWF+6oWASXxjzKAuu74gdXPsS+9h4GyWUJklF -kNJai+f3WmZabZf5uJWIDoTkWqX894YEnwUolAqVH3yuXC0HVKp6FTDtv6rKD3hS -hHq3sFuOVVRW0DuODHVHawKBgAaqdL6dnecftwiCji2aR2r4+E/3O1oCiScKXQAH -uy3CsR1L1qoOZEcxOJxAw2G6ZoXQNTcqHm6+G3oKNOuqu89HxpnFhuz6B8i+R5+D -ToqBmbm2y5T9uNJc9UZYxS8fzMpzN8YN4JIhGbM33NVghVqQj/ui6h/jOspg1B1d -ZDLhAoGARp2O4SO0DJpsSuMR0NUPlCuADxLToDBhZ5ookagiRQEPoNcIU4fP8sJJ -/CUQvF0DRZustcvS0Rb+gnZOMda9Iq2R8Jrjbj4qZhlyPXf5ynrEekj3UFFZtvHg -ubfV/oc0SPgcIZWP/Ffqa8S3hI139UOFGKCuvKEtsWkgM7MJByA= ------END RSA PRIVATE KEY----- diff --git a/test/fixtures/env.empty b/test/fixtures/env.empty deleted file mode 100644 index 8b13789..0000000 --- a/test/fixtures/env.empty +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/fixtures/env.env b/test/fixtures/env.env deleted file mode 100644 index b041a65..0000000 --- a/test/fixtures/env.env +++ /dev/null @@ -1,5 +0,0 @@ -port=80 -bind=0.0.0.0 -mysql_host=localhost -mysql_user=toast -mysql_pass=peanutbutter diff --git a/test/fixtures/env.json b/test/fixtures/env.json deleted file mode 100644 index f5ca76c..0000000 --- a/test/fixtures/env.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "port": 80, - "bind": "0.0.0.0", - "mysql":{ - "host":"localhost", - "user":"toast", - "pass":"peanutbutter" - } -} diff --git a/test/fixtures/env.path b/test/fixtures/env.path deleted file mode 100644 index 327d57f..0000000 --- a/test/fixtures/env.path +++ /dev/null @@ -1 +0,0 @@ -PATH=/some/invalid:/path/option diff --git a/test/fixtures/env.port b/test/fixtures/env.port deleted file mode 100644 index 2fc80e3..0000000 --- a/test/fixtures/env.port +++ /dev/null @@ -1 +0,0 @@ -PORT=3000 diff --git a/test/fixtures/procfile-comment/.env b/test/fixtures/procfile-comment/.env deleted file mode 100644 index 33a7c96..0000000 --- a/test/fixtures/procfile-comment/.env +++ /dev/null @@ -1 +0,0 @@ -PATH=something-totally-bogus diff --git a/test/fixtures/procfile-comment/Procfile b/test/fixtures/procfile-comment/Procfile deleted file mode 100644 index e82ae61..0000000 --- a/test/fixtures/procfile-comment/Procfile +++ /dev/null @@ -1,3 +0,0 @@ -#norun: touch should-not-exist.js -run: touch should-exist.js -# norun: touch should-not-exist-2.js diff --git a/test/fixtures/procfile-comment/foreman-run.conf b/test/fixtures/procfile-comment/foreman-run.conf deleted file mode 100644 index 5065003..0000000 --- a/test/fixtures/procfile-comment/foreman-run.conf +++ /dev/null @@ -1,56 +0,0 @@ -#foreman-run - -# Generated by node-foreman - -description "foreman-run service" - -# Automatic start/stop based on foreman, which starts on bootup -# To manually start/stop only this job: -# /sbin/initctl start foreman-run -# /sbin/initctl stop foreman-run -start on starting foreman -stop on stopping foreman -respawn - -# Configuration for this daemon -env PATH="something-totally-bogus" - - -# Not supported by older versions of Upstart, like on RHEL/CentOS -chdir TEST_DIR -setuid root -setgid root - -# Arbitrarily high limit on number of open file descriptors -limit nofile 50000 50000 - -# Enable core dumps -limit core unlimited unlimited - -# How to run the application -script - - # Abort if some part of this script fails - set -e - - # Temporary fifo for sending log output to - mkfifo /tmp/foreman-run-log-fifo - - # A logger instance that pipes the fifo to syslog - ( logger -t foreman-run /tmp/foreman-run-log-fifo - - # Clean up the fifo so we don't leave it laying around - rm /tmp/foreman-run-log-fifo - - # Run our actual application - # - exec used instead of setuid, see comment above - # - stderr redirection is done last so that we don't lose error messages - # related to the Upstart config itself - # Uncomment and use this line if you are using an older version of Upstart - #exec su -m -s /bin/sh -c 'exec "$0" "$@"' root -- npm start 2>&1 - exec touch should-exist.js 2>&1 - -end script diff --git a/test/fixtures/procfile-comment/foreman.conf b/test/fixtures/procfile-comment/foreman.conf deleted file mode 100644 index afa8323..0000000 --- a/test/fixtures/procfile-comment/foreman.conf +++ /dev/null @@ -1,17 +0,0 @@ -#foreman - -description "foreman super launcher" - -# Start on boot/reboot up -start on runlevel [2345] - -# Stop on shutdown/reboot -stop on runlevel [016] - -# To start/stop all workers under this app manually you can run: -# -# /sbin/initctl start foreman -# /sbin/initctl stop foreman -# -# For instructions on starting/stopping the individual components of this app, -# see the start/stop descriptions in their Upstart job configurations. diff --git a/test/fixtures/supervisord/supervisord-test-api-1.conf b/test/fixtures/supervisord/supervisord-test-api-1.conf deleted file mode 100644 index d030511..0000000 --- a/test/fixtures/supervisord/supervisord-test-api-1.conf +++ /dev/null @@ -1,11 +0,0 @@ -[program:supervisord-test-api-1] -command=node server.js 10000 -autostart=true -autorestart=true -stopsignal=QUIT -stdout_logfile=/var/log/supervisord-test-api-1.stdout.log -stderr_logfile=/var/log/supervisord-test-api-1.stderr.log -user=test-user -directory=TEST_DIR -environment=PATH="TEST_PATH",bind="0.0.0.0",mysql_host="localhost",mysql_pass="peanutbutter",mysql_user="toast",port="80",PORT="5100",FOREMAN_WORKER_NAME="api.1" - diff --git a/test/fixtures/supervisord/supervisord-test-log-1.conf b/test/fixtures/supervisord/supervisord-test-log-1.conf deleted file mode 100644 index 9810ace..0000000 --- a/test/fixtures/supervisord/supervisord-test-log-1.conf +++ /dev/null @@ -1,11 +0,0 @@ -[program:supervisord-test-log-1] -command=node server.js 100000 -autostart=true -autorestart=true -stopsignal=QUIT -stdout_logfile=/var/log/supervisord-test-log-1.stdout.log -stderr_logfile=/var/log/supervisord-test-log-1.stderr.log -user=test-user -directory=TEST_DIR -environment=PATH="TEST_PATH",bind="0.0.0.0",mysql_host="localhost",mysql_pass="peanutbutter",mysql_user="toast",port="80",PORT="5200",FOREMAN_WORKER_NAME="log.1" - diff --git a/test/fixtures/supervisord/supervisord-test-web-1.conf b/test/fixtures/supervisord/supervisord-test-web-1.conf deleted file mode 100644 index 8053c09..0000000 --- a/test/fixtures/supervisord/supervisord-test-web-1.conf +++ /dev/null @@ -1,11 +0,0 @@ -[program:supervisord-test-web-1] -command=node server.js 5000 -autostart=true -autorestart=true -stopsignal=QUIT -stdout_logfile=/var/log/supervisord-test-web-1.stdout.log -stderr_logfile=/var/log/supervisord-test-web-1.stderr.log -user=test-user -directory=TEST_DIR -environment=PATH="TEST_PATH",bind="0.0.0.0",mysql_host="localhost",mysql_pass="peanutbutter",mysql_user="toast",port="80",PORT="5000",FOREMAN_WORKER_NAME="web.1" - diff --git a/test/fixtures/supervisord/supervisord-test.conf b/test/fixtures/supervisord/supervisord-test.conf deleted file mode 100644 index 1a1594a..0000000 --- a/test/fixtures/supervisord/supervisord-test.conf +++ /dev/null @@ -1,2 +0,0 @@ -[group:supervisord-test] -programs=supervisord-test-web-1,supervisord-test-api-1,supervisord-test-log-1 diff --git a/test/fixtures/systemd/systemd-test-api-1.service b/test/fixtures/systemd/systemd-test-api-1.service deleted file mode 100644 index 3302321..0000000 --- a/test/fixtures/systemd/systemd-test-api-1.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=systemd-test-api-1 -Requires=systemd-test-api.target - -[Service] -Type=simple -ExecStart=/usr/bin/env node server.js 10000 -WorkingDirectory=TEST_DIR - -User=test-user -Group=test-user - -EnvironmentFile=-TEST_DIR/fixtures/env.env -Environment=PORT=5100 - -StandardInput=null -StandardOutput=syslog -StandardError=syslog -Restart=always diff --git a/test/fixtures/systemd/systemd-test-api.target b/test/fixtures/systemd/systemd-test-api.target deleted file mode 100644 index bc0ae63..0000000 --- a/test/fixtures/systemd/systemd-test-api.target +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -Requires=systemd-test.target -Wants= systemd-test-api-1.service diff --git a/test/fixtures/systemd/systemd-test-log-1.service b/test/fixtures/systemd/systemd-test-log-1.service deleted file mode 100644 index a1e1f15..0000000 --- a/test/fixtures/systemd/systemd-test-log-1.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=systemd-test-log-1 -Requires=systemd-test-log.target - -[Service] -Type=simple -ExecStart=/usr/bin/env node server.js 100000 -WorkingDirectory=TEST_DIR - -User=test-user -Group=test-user - -EnvironmentFile=-TEST_DIR/fixtures/env.env -Environment=PORT=5200 - -StandardInput=null -StandardOutput=syslog -StandardError=syslog -Restart=always diff --git a/test/fixtures/systemd/systemd-test-log.target b/test/fixtures/systemd/systemd-test-log.target deleted file mode 100644 index db70b4a..0000000 --- a/test/fixtures/systemd/systemd-test-log.target +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -Requires=systemd-test.target -Wants= systemd-test-log-1.service diff --git a/test/fixtures/systemd/systemd-test-web-1.service b/test/fixtures/systemd/systemd-test-web-1.service deleted file mode 100644 index f3f6ca1..0000000 --- a/test/fixtures/systemd/systemd-test-web-1.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=systemd-test-web-1 -Requires=systemd-test-web.target - -[Service] -Type=simple -ExecStart=/usr/bin/env node server.js 5000 -WorkingDirectory=TEST_DIR - -User=test-user -Group=test-user - -EnvironmentFile=-TEST_DIR/fixtures/env.env -Environment=PORT=5000 - -StandardInput=null -StandardOutput=syslog -StandardError=syslog -Restart=always diff --git a/test/fixtures/systemd/systemd-test-web.target b/test/fixtures/systemd/systemd-test-web.target deleted file mode 100644 index 7699134..0000000 --- a/test/fixtures/systemd/systemd-test-web.target +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -Requires=systemd-test.target -Wants= systemd-test-web-1.service diff --git a/test/fixtures/systemd/systemd-test.target b/test/fixtures/systemd/systemd-test.target deleted file mode 100644 index 3f41ce6..0000000 --- a/test/fixtures/systemd/systemd-test.target +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Wants= systemd-test-web.target systemd-test-api.target systemd-test-log.target - -[Install] -WantedBy=multi-user.target diff --git a/test/fixtures/upstart-custom-templates/foreman-APP-N.conf b/test/fixtures/upstart-custom-templates/foreman-APP-N.conf deleted file mode 100644 index 8a044fc..0000000 --- a/test/fixtures/upstart-custom-templates/foreman-APP-N.conf +++ /dev/null @@ -1,14 +0,0 @@ -# CUSTOM {{{application}}}-{{{process}}}-{{{number}}} -start on starting {{{application}}}-{{{process}}} -stop on stopping {{{application}}}-{{{process}}} -respawn - -{{#envs}}env {{{key}}}="{{{value}}}" -{{/envs}} - - -chdir {{{cwd}}} -setuid {{{user}}} -setgid {{{group}}} - -exec {{{command}}} >> {{{logs}}}/{{{application}}}/{{{process}}}-{{{number}}}.log 2>&1 diff --git a/test/fixtures/upstart-custom-templates/foreman-APP.conf b/test/fixtures/upstart-custom-templates/foreman-APP.conf deleted file mode 100644 index 6d157bc..0000000 --- a/test/fixtures/upstart-custom-templates/foreman-APP.conf +++ /dev/null @@ -1,4 +0,0 @@ -# CUSTOM {{{application}}}-{{{process}}} -start on starting {{{application}}} -stop on stopping {{{application}}} - diff --git a/test/fixtures/upstart-custom-templates/foreman.conf b/test/fixtures/upstart-custom-templates/foreman.conf deleted file mode 100644 index 23bce32..0000000 --- a/test/fixtures/upstart-custom-templates/foreman.conf +++ /dev/null @@ -1,13 +0,0 @@ -# CUSTOM {{{application}}} -pre-start script - -bash << "EOF" - mkdir -p {{{logs}}}/{{{application}}} - chown -R {{{user}}} {{{logs}}}/{{{application}}} -EOF - -end script - -start on runlevel [2345] - -stop on runlevel [016] diff --git a/test/fixtures/upstart-custom/upstart-test-api-1.conf b/test/fixtures/upstart-custom/upstart-test-api-1.conf deleted file mode 100644 index 5474059..0000000 --- a/test/fixtures/upstart-custom/upstart-test-api-1.conf +++ /dev/null @@ -1,20 +0,0 @@ -# CUSTOM upstart-test-api-1 -start on starting upstart-test-api -stop on stopping upstart-test-api -respawn - -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" -env PORT="5100" -env FOREMAN_WORKER_NAME="api.1" - - -chdir TEST_DIR -setuid test-user -setgid test-user - -exec node server.js 10000 >> /var/log/upstart-test/api-1.log 2>&1 diff --git a/test/fixtures/upstart-custom/upstart-test-api.conf b/test/fixtures/upstart-custom/upstart-test-api.conf deleted file mode 100644 index 6937fdd..0000000 --- a/test/fixtures/upstart-custom/upstart-test-api.conf +++ /dev/null @@ -1,4 +0,0 @@ -# CUSTOM upstart-test-api -start on starting upstart-test -stop on stopping upstart-test - diff --git a/test/fixtures/upstart-custom/upstart-test-log-1.conf b/test/fixtures/upstart-custom/upstart-test-log-1.conf deleted file mode 100644 index 9c3029b..0000000 --- a/test/fixtures/upstart-custom/upstart-test-log-1.conf +++ /dev/null @@ -1,20 +0,0 @@ -# CUSTOM upstart-test-log-1 -start on starting upstart-test-log -stop on stopping upstart-test-log -respawn - -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" -env PORT="5200" -env FOREMAN_WORKER_NAME="log.1" - - -chdir TEST_DIR -setuid test-user -setgid test-user - -exec node server.js 100000 >> /var/log/upstart-test/log-1.log 2>&1 diff --git a/test/fixtures/upstart-custom/upstart-test-log.conf b/test/fixtures/upstart-custom/upstart-test-log.conf deleted file mode 100644 index 1e4fb74..0000000 --- a/test/fixtures/upstart-custom/upstart-test-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -# CUSTOM upstart-test-log -start on starting upstart-test -stop on stopping upstart-test - diff --git a/test/fixtures/upstart-custom/upstart-test-web-1.conf b/test/fixtures/upstart-custom/upstart-test-web-1.conf deleted file mode 100644 index 8492a4b..0000000 --- a/test/fixtures/upstart-custom/upstart-test-web-1.conf +++ /dev/null @@ -1,20 +0,0 @@ -# CUSTOM upstart-test-web-1 -start on starting upstart-test-web -stop on stopping upstart-test-web -respawn - -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" -env PORT="5000" -env FOREMAN_WORKER_NAME="web.1" - - -chdir TEST_DIR -setuid test-user -setgid test-user - -exec node server.js 5000 >> /var/log/upstart-test/web-1.log 2>&1 diff --git a/test/fixtures/upstart-custom/upstart-test-web.conf b/test/fixtures/upstart-custom/upstart-test-web.conf deleted file mode 100644 index 4d8a81a..0000000 --- a/test/fixtures/upstart-custom/upstart-test-web.conf +++ /dev/null @@ -1,4 +0,0 @@ -# CUSTOM upstart-test-web -start on starting upstart-test -stop on stopping upstart-test - diff --git a/test/fixtures/upstart-custom/upstart-test.conf b/test/fixtures/upstart-custom/upstart-test.conf deleted file mode 100644 index 07d19b4..0000000 --- a/test/fixtures/upstart-custom/upstart-test.conf +++ /dev/null @@ -1,13 +0,0 @@ -# CUSTOM upstart-test -pre-start script - -bash << "EOF" - mkdir -p /var/log/upstart-test - chown -R test-user /var/log/upstart-test -EOF - -end script - -start on runlevel [2345] - -stop on runlevel [016] diff --git a/test/fixtures/upstart-single/upstart-single-test-api.conf b/test/fixtures/upstart-single/upstart-single-test-api.conf deleted file mode 100644 index 24d4ee7..0000000 --- a/test/fixtures/upstart-single/upstart-single-test-api.conf +++ /dev/null @@ -1,61 +0,0 @@ -#upstart-single-test-api - -# Generated by node-foreman - -description "upstart-single-test-api service" - -# Automatic start/stop based on upstart-single-test, which starts on bootup -# To manually start/stop only this job: -# /sbin/initctl start upstart-single-test-api -# /sbin/initctl stop upstart-single-test-api -start on starting upstart-single-test -stop on stopping upstart-single-test -respawn - -# Configuration for this daemon -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" - - -# Not supported by older versions of Upstart, like on RHEL/CentOS -chdir TEST_DIR -setuid test-user -setgid test-user - -# Arbitrarily high limit on number of open file descriptors -limit nofile 50000 50000 - -# Enable core dumps -limit core unlimited unlimited - -# How to run the application -script - - # Abort if some part of this script fails - set -e - - # Temporary fifo for sending log output to - mkfifo /tmp/upstart-single-test-api-log-fifo - - # A logger instance that pipes the fifo to syslog - ( logger -t upstart-single-test-api /tmp/upstart-single-test-api-log-fifo - - # Clean up the fifo so we don't leave it laying around - rm /tmp/upstart-single-test-api-log-fifo - - # Run our actual application - # - exec used instead of setuid, see comment above - # - stderr redirection is done last so that we don't lose error messages - # related to the Upstart config itself - # Uncomment and use this line if you are using an older version of Upstart - #exec su -m -s /bin/sh -c 'exec "$0" "$@"' test-user -- npm start 2>&1 - exec node server.js 10000 2>&1 - -end script diff --git a/test/fixtures/upstart-single/upstart-single-test-log.conf b/test/fixtures/upstart-single/upstart-single-test-log.conf deleted file mode 100644 index de921fa..0000000 --- a/test/fixtures/upstart-single/upstart-single-test-log.conf +++ /dev/null @@ -1,61 +0,0 @@ -#upstart-single-test-log - -# Generated by node-foreman - -description "upstart-single-test-log service" - -# Automatic start/stop based on upstart-single-test, which starts on bootup -# To manually start/stop only this job: -# /sbin/initctl start upstart-single-test-log -# /sbin/initctl stop upstart-single-test-log -start on starting upstart-single-test -stop on stopping upstart-single-test -respawn - -# Configuration for this daemon -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" - - -# Not supported by older versions of Upstart, like on RHEL/CentOS -chdir TEST_DIR -setuid test-user -setgid test-user - -# Arbitrarily high limit on number of open file descriptors -limit nofile 50000 50000 - -# Enable core dumps -limit core unlimited unlimited - -# How to run the application -script - - # Abort if some part of this script fails - set -e - - # Temporary fifo for sending log output to - mkfifo /tmp/upstart-single-test-log-log-fifo - - # A logger instance that pipes the fifo to syslog - ( logger -t upstart-single-test-log /tmp/upstart-single-test-log-log-fifo - - # Clean up the fifo so we don't leave it laying around - rm /tmp/upstart-single-test-log-log-fifo - - # Run our actual application - # - exec used instead of setuid, see comment above - # - stderr redirection is done last so that we don't lose error messages - # related to the Upstart config itself - # Uncomment and use this line if you are using an older version of Upstart - #exec su -m -s /bin/sh -c 'exec "$0" "$@"' test-user -- npm start 2>&1 - exec node server.js 100000 2>&1 - -end script diff --git a/test/fixtures/upstart-single/upstart-single-test-web.conf b/test/fixtures/upstart-single/upstart-single-test-web.conf deleted file mode 100644 index 39f93db..0000000 --- a/test/fixtures/upstart-single/upstart-single-test-web.conf +++ /dev/null @@ -1,61 +0,0 @@ -#upstart-single-test-web - -# Generated by node-foreman - -description "upstart-single-test-web service" - -# Automatic start/stop based on upstart-single-test, which starts on bootup -# To manually start/stop only this job: -# /sbin/initctl start upstart-single-test-web -# /sbin/initctl stop upstart-single-test-web -start on starting upstart-single-test -stop on stopping upstart-single-test -respawn - -# Configuration for this daemon -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" - - -# Not supported by older versions of Upstart, like on RHEL/CentOS -chdir TEST_DIR -setuid test-user -setgid test-user - -# Arbitrarily high limit on number of open file descriptors -limit nofile 50000 50000 - -# Enable core dumps -limit core unlimited unlimited - -# How to run the application -script - - # Abort if some part of this script fails - set -e - - # Temporary fifo for sending log output to - mkfifo /tmp/upstart-single-test-web-log-fifo - - # A logger instance that pipes the fifo to syslog - ( logger -t upstart-single-test-web /tmp/upstart-single-test-web-log-fifo - - # Clean up the fifo so we don't leave it laying around - rm /tmp/upstart-single-test-web-log-fifo - - # Run our actual application - # - exec used instead of setuid, see comment above - # - stderr redirection is done last so that we don't lose error messages - # related to the Upstart config itself - # Uncomment and use this line if you are using an older version of Upstart - #exec su -m -s /bin/sh -c 'exec "$0" "$@"' test-user -- npm start 2>&1 - exec node server.js 5000 2>&1 - -end script diff --git a/test/fixtures/upstart-single/upstart-single-test.conf b/test/fixtures/upstart-single/upstart-single-test.conf deleted file mode 100644 index ddbfb14..0000000 --- a/test/fixtures/upstart-single/upstart-single-test.conf +++ /dev/null @@ -1,17 +0,0 @@ -#upstart-single-test - -description "upstart-single-test super launcher" - -# Start on boot/reboot up -start on runlevel [2345] - -# Stop on shutdown/reboot -stop on runlevel [016] - -# To start/stop all workers under this app manually you can run: -# -# /sbin/initctl start upstart-single-test -# /sbin/initctl stop upstart-single-test -# -# For instructions on starting/stopping the individual components of this app, -# see the start/stop descriptions in their Upstart job configurations. diff --git a/test/fixtures/upstart/upstart-test-api-1.conf b/test/fixtures/upstart/upstart-test-api-1.conf deleted file mode 100644 index 3492daf..0000000 --- a/test/fixtures/upstart/upstart-test-api-1.conf +++ /dev/null @@ -1,20 +0,0 @@ -#upstart-test-api-1 -start on starting upstart-test-api -stop on stopping upstart-test-api -respawn - -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" -env PORT="5100" -env FOREMAN_WORKER_NAME="api.1" - - -chdir /EXPORT/PATH -setuid test-user -setgid test-user - -exec node server.js 10000 >> /var/log/upstart-test/api-1.log 2>&1 diff --git a/test/fixtures/upstart/upstart-test-api.conf b/test/fixtures/upstart/upstart-test-api.conf deleted file mode 100644 index 5217b02..0000000 --- a/test/fixtures/upstart/upstart-test-api.conf +++ /dev/null @@ -1,4 +0,0 @@ -#upstart-test-api -start on starting upstart-test -stop on stopping upstart-test - diff --git a/test/fixtures/upstart/upstart-test-log-1.conf b/test/fixtures/upstart/upstart-test-log-1.conf deleted file mode 100644 index 69c3032..0000000 --- a/test/fixtures/upstart/upstart-test-log-1.conf +++ /dev/null @@ -1,20 +0,0 @@ -#upstart-test-log-1 -start on starting upstart-test-log -stop on stopping upstart-test-log -respawn - -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" -env PORT="5200" -env FOREMAN_WORKER_NAME="log.1" - - -chdir /EXPORT/PATH -setuid test-user -setgid test-user - -exec node server.js 100000 >> /var/log/upstart-test/log-1.log 2>&1 diff --git a/test/fixtures/upstart/upstart-test-log.conf b/test/fixtures/upstart/upstart-test-log.conf deleted file mode 100644 index 92af341..0000000 --- a/test/fixtures/upstart/upstart-test-log.conf +++ /dev/null @@ -1,4 +0,0 @@ -#upstart-test-log -start on starting upstart-test -stop on stopping upstart-test - diff --git a/test/fixtures/upstart/upstart-test-web-1.conf b/test/fixtures/upstart/upstart-test-web-1.conf deleted file mode 100644 index a9fdac7..0000000 --- a/test/fixtures/upstart/upstart-test-web-1.conf +++ /dev/null @@ -1,20 +0,0 @@ -#upstart-test-web-1 -start on starting upstart-test-web -stop on stopping upstart-test-web -respawn - -env PATH="TEST_PATH" -env bind="0.0.0.0" -env mysql_host="localhost" -env mysql_pass="peanutbutter" -env mysql_user="toast" -env port="80" -env PORT="5000" -env FOREMAN_WORKER_NAME="web.1" - - -chdir /EXPORT/PATH -setuid test-user -setgid test-user - -exec node server.js 5000 >> /var/log/upstart-test/web-1.log 2>&1 diff --git a/test/fixtures/upstart/upstart-test-web.conf b/test/fixtures/upstart/upstart-test-web.conf deleted file mode 100644 index 1e1b985..0000000 --- a/test/fixtures/upstart/upstart-test-web.conf +++ /dev/null @@ -1,4 +0,0 @@ -#upstart-test-web -start on starting upstart-test -stop on stopping upstart-test - diff --git a/test/fixtures/upstart/upstart-test.conf b/test/fixtures/upstart/upstart-test.conf deleted file mode 100644 index fdbf3e9..0000000 --- a/test/fixtures/upstart/upstart-test.conf +++ /dev/null @@ -1,13 +0,0 @@ -#upstart-test -pre-start script - -bash << "EOF" - mkdir -p /var/log/upstart-test - chown -R test-user /var/log/upstart-test -EOF - -end script - -start on runlevel [2345] - -stop on runlevel [016] diff --git a/test/handle-eperm.test.sh b/test/handle-eperm.test.sh deleted file mode 100755 index 2702b19..0000000 --- a/test/handle-eperm.test.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" - -rm -rf sandbox -mkdir -p sandbox - -# We'll exit with a code that cannot be used as a signal. This exposes a -# potential bug in termination handling. -printf "exitwithcode: sudo sleep 1\ncrashafterawhile: sleep 0.5; exit 123" > sandbox/Procfile -node ../nf.js --procfile sandbox/Procfile start >sandbox/eperm.txt 2>&1 && exit 0 - -exit 1 - diff --git a/test/procfile-comment.test.sh b/test/procfile-comment.test.sh deleted file mode 100755 index 6670421..0000000 --- a/test/procfile-comment.test.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" -SED=`which gsed || which sed` - -rm -rf sandbox -mkdir -p sandbox - -echo "PATH=something-totally-bogus" > sandbox/.env -printf "#norun: touch should-not-exist.js\nrun: touch should-exist.js\n# norun: touch should-not-exist-2.js\n" > sandbox/Procfile - -node ../nf.js export --out sandbox --env sandbox/.env --type upstart-single --procfile sandbox/Procfile - -$SED -i '' -e "s%$(pwd)%TEST_DIR%g" \ - -e "s%$(dirname $(which node))%TEST_PATH%g" sandbox/* - -# Fixtures can be updated to match output by running `npm test --update-fixtures` -test -n "$npm_config_update_fixtures" && cp sandbox/* fixtures/procfile-comment/ - -diff -r -u fixtures/procfile-comment sandbox 1>&2 || exit $? diff --git a/test/proxy-ssl.test.js b/test/proxy-ssl.test.js deleted file mode 100644 index e276fe1..0000000 --- a/test/proxy-ssl.test.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright IBM Corp. 2015,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var events = require('events'); -var https = require('https'); - -var startServer = require('./server').startServer; -var startProxies = require('../lib/proxy').startProxies; - -var emitter = new events.EventEmitter(); - -var proxy_port = 0; - -var reqs = { - 'test-web': 1 -}; -var proc = { - 'test-web': '' -}; -var command = { - proxy: proxy_port.toString(), - sslCert: './fixtures/certs/my-server.crt.pem', - sslKey: './fixtures/certs/my-server.key.pem' -}; - -startServer(0, emitter).on('listening', function() { - console.error('test server listening:', this.address()); - startProxies(reqs, proc, command, emitter, this.address().port); - emitter.once('https', function(port) { - proxy_port = port; - test_proxy(); - }); -}); - -function test_proxy() { - https.get({ - port: proxy_port, - rejectUnauthorized: false - }, function (response) { - assert.equal(response.statusCode, 200); - - var body = ''; - response.setEncoding('utf8'); - response.on('data', function (chunk) { - body += chunk; - }); - response.on('end', function () { - body = JSON.parse(body); - assert.equal(body.request.headers['x-forwarded-proto'], 'https'); - - // Only after the response has been returned can we shut down properly - emitter.emit('killall', 'SIGINT'); - }); - }); -} diff --git a/test/proxy.test.js b/test/proxy.test.js deleted file mode 100644 index e43aeb9..0000000 --- a/test/proxy.test.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright IBM Corp. 2015,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var events = require('events'); -var http = require('http'); - -var startServer = require('./server').startServer; -var startProxies = require('../lib/proxy').startProxies; - -var emitter = new events.EventEmitter(); - -var proxy_port = 0; - -var reqs = { - 'test-web': 1 -}; -var proc = { - 'test-web': '' -}; -var command = { - proxy: proxy_port.toString() -}; - -startServer(0, emitter).on('listening', function() { - console.error('test server listening:', this.address()); - startProxies(reqs, proc, command, emitter, this.address().port); - emitter.once('http', function(port) { - proxy_port = port; - test_proxy(); - }); -}); - -function test_proxy() { - http.get({ - port: proxy_port - }, function (response) { - assert.equal(response.statusCode, 200); - - var body = ''; - response.setEncoding('utf8'); - response.on('data', function (chunk) { - body += chunk; - }); - response.on('end', function () { - body = JSON.parse(body); - assert.equal(body.request.headers['x-forwarded-proto'], 'http'); - - // Only after the response has been returned can we shut down properly - emitter.emit('killall', 'SIGINT'); - }); - }); -} diff --git a/test/run-once.test.js b/test/run-once.test.js deleted file mode 100644 index 75fddd3..0000000 --- a/test/run-once.test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var assert = require('assert'); -var rimraf = require('rimraf'); -var fs = require('fs'); -var once = require('../lib/proc').once; - -var envs = { FILENAME: "should-also-exist.txt" }; -var callbackCounter = 0; -var callbackIncrementer = function(code){ - if(code === 0) { - callbackCounter++; - } -}; - -rimraf.sync('./sandbox'); -fs.mkdirSync('./sandbox'); -process.chdir('./sandbox'); - -assert.equal(fs.existsSync('./should-exist.txt'), false); -assert.equal(fs.existsSync('./should-also-exist.txt'), false); -assert.equal(fs.existsSync('./should-not-exist.txt'), false); - -once("touch should-exist.txt", null, callbackIncrementer); -// TODO: this is currently OS dependent, but we should probably do the -// expansion ourselves -if (process.platform === 'win32') { - once("touch %FILENAME%", envs, callbackIncrementer); -} else { - once("touch $FILENAME", envs, callbackIncrementer); -} - -process.on('exit', function() { - assert.equal(callbackCounter, 2); - assert.equal(fs.existsSync('./should-exist.txt'), true); - assert.equal(fs.existsSync('./should-not-exist.txt'), false); - assert.equal(fs.existsSync(envs.FILENAME), true, 'should exist: ' + envs.FILENAME); -}); diff --git a/test/server.js b/test/server.js deleted file mode 100644 index fc4d6f2..0000000 --- a/test/server.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright IBM Corp. 2015,2016. All Rights Reserved. -// Node module: foreman -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -var http = require('http'); - -/** - * Starts an HTTP server listening on `port` that will clean up and kill itself - * upon a 'killall' event' - * - * @param {Number} port - the port to listen on - * @param {EventEmitter} emitter - the emitter to listen for 'killall' on - * @return {http.Server} - */ -module.exports.startServer = function startServer(port, emitter) { - var server = http.createServer(function (request, response) { - response.statusCode = 200; - // Send back the request headers so the test can validate that the - // x-forwarded-* headers were set. - response.write(JSON.stringify({ - request: { - headers: request.headers - } - })); - response.end(); - }); - - // Keep track of the sockets so that we can destroy them and end the process - // gracefully. - var nextSocketId = 0; - var sockets = []; - - server.on('connection', function (socket) { - var socketId = nextSocketId++; - sockets[socketId] = socket; - socket.on('close', function () { - delete sockets[socketId]; - }); - }); - - server.listen(port, '127.0.0.1'); - - emitter.once('killall', function () { - server.close(); - for (var socketId in sockets) { - sockets[socketId].destroy(); - } - }); - - return server; -}; diff --git a/test/start-honours-env-port.test.sh b/test/start-honours-env-port.test.sh deleted file mode 100755 index 50f74df..0000000 --- a/test/start-honours-env-port.test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" - -rm -rf sandbox -mkdir -p sandbox - -PORT=4000 node ../nf.js --procfile fixtures/Procfile.port --env fixtures/env.empty start > sandbox/ports.txt - -# default is 5000, actual environment specifies 4000 -grep -q -F -e 4000 sandbox/ports.txt && \ - grep -q -F -e 4100 sandbox/ports.txt && \ - grep -q -F -e 4200 sandbox/ports.txt && exit 0 - -exit 1 diff --git a/test/start-honours-port.test.sh b/test/start-honours-port.test.sh deleted file mode 100755 index fe1473f..0000000 --- a/test/start-honours-port.test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -NF="node ../nf.js" - -rm -rf sandbox -mkdir -p sandbox - -node ../nf.js --procfile fixtures/Procfile.port --env fixtures/env.port start > sandbox/ports.txt - -# default is 5000, env.port specifies 3000 -grep -q -F -e 3000 sandbox/ports.txt && \ - grep -q -F -e 3100 sandbox/ports.txt && \ - grep -q -F -e 3200 sandbox/ports.txt && exit 0 - -exit 1