Permalink
Browse files

add support for multiple servers

  • Loading branch information...
1 parent 6903d4e commit 08902105568f9e738d82134cc97316a97b684761 Unai Orbe committed Feb 9, 2014
Showing with 40 additions and 17 deletions.
  1. +11 −4 Gruntfile.js
  2. +20 −11 README.md
  3. +2 −2 tasks/forever-task.js
  4. +7 −0 test/fixtures/index2.js
View
@@ -37,8 +37,15 @@ module.exports = function(grunt) {
tests: ['test/*_test.js']
},
forever: {
- options: {
- index: './test/fixtures/index.js'
+ test: {
+ options: {
+ index: './test/fixtures/index.js'
+ }
+ },
+ test2: {
+ options: {
+ index: './test/fixtures/index2.js'
+ }
}
}
@@ -55,5 +62,5 @@ module.exports = function(grunt) {
// By default, lint and run all tests.
grunt.registerTask('test', ['nodeunit']);
grunt.registerTask('default', ['jshint', 'test']);
-
-};
+
+};
View
@@ -1,4 +1,4 @@
-grunt-forever [![Build Status](https://travis-ci.org/bustardcelly/grunt-forever.png)](https://travis-ci.org/bustardcelly/grunt-forever)
+grunt-forever
=============
> forever task for grunt to start, stop and restart an application as a daemon.
@@ -22,11 +22,11 @@ Inside your `grunt.js` file add a section named `forever`. This section specifie
#### Named Arguments
grunt-forever uses colon-separated arguments for the `forever` task described in the [grunt API](https://github.com/gruntjs/grunt/wiki/grunt.task#wiki-grunt-task-registerTask). Supported name arguments are:
-* forever:start
-* forever:stop
-* forever:restart
+* forever:server:start
+* forever:server:stop
+* forever:server:restart
-##### start
+##### start
Attempts to start the main application file as a daemon if not currently running.
@@ -64,22 +64,31 @@ File stdout is logged into, defaults to 'out.log'.
### Config Example
```javascript
forever: {
- options: {
- index: 'index.js',
- logDir: 'logs'
+ server1: {
+ options: {
+ index: 'index.js',
+ logDir: 'logs'
+ }
+ },
+
+ server2: {
+ options: {
+ index: 'otherindex.js',
+ logDir: 'logs'
+ }
}
}
```
### Command example
```bash
-grunt forever:start
+grunt forever:server1:start
```
```bash
-grunt forever:stop
+grunt forever:server2:stop
```
```bash
-grunt forever:restart
+grunt forever:server1:restart
```
View
@@ -163,10 +163,10 @@ function restartOnProcess( index ) {
module.exports = function(grunt) {
gruntRef = grunt;
- grunt.registerTask( 'forever', 'Starts node app as a daemon.', function(target) {
+ grunt.registerMultiTask( 'forever', 'Starts node app as a daemon.', function(target) {
var index = this.options().index || 'index.js',
- operation = target;
+ operation = target || 'start';
commandName = this.options().command;
if (this.options().logDir) {
View
@@ -0,0 +1,7 @@
+var http = require('http');
+
+// http://nodejs.org/
+http.createServer(function (req, res) {
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end('Hello World\n');
+}).listen(1337, '127.0.0.1');

0 comments on commit 0890210

Please sign in to comment.