Skip to content

Commit 654dd0a

Browse files
committed
Added instructions for installing as a windows service
1 parent d99efdd commit 654dd0a

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

docs/node-windows.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Install as Windows Service
2+
==========================
3+
4+
Prerequisites
5+
-------------
6+
7+
Before you start, ensure that the following are installed on the Windows server:
8+
9+
* mongodb
10+
* nodejs
11+
12+
Installation
13+
------------
14+
15+
Build a production version of Command Post
16+
17+
```
18+
npm install
19+
grunt production
20+
rm -r node_modules
21+
npm install --production
22+
```
23+
24+
Install CommandPost as service
25+
26+
```
27+
npm install -g node-windows
28+
node scripts\install-windows-service.js
29+
```
30+
31+
This will setup a windows service called `CommandPost` which will listen on
32+
port 80 in development mode. To change port or mode, edit the `install-windows-service.js`

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ Install
112112
6. `npm install -g grunt-cli`
113113
7. `grunt`
114114

115-
For installation on Windows see the [iisnode readme](docs/iisnode/readme.md).
115+
For installation on Windows see the [iisnode readme](docs/iisnode/readme.md)
116+
or [node-windows](docs/node-windows.md).
116117

117118
Configuration
118119
-------------

scripts/install-windows-service.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var Service = require('node-windows').Service;
2+
3+
var svc = new Service({
4+
name: 'CommandPost',
5+
description: 'Command Post HTTP Server',
6+
script: require('path').join(__dirname, '../app.js'),
7+
env: [
8+
{ name: 'NODE_ENV', value: 'production' },
9+
{ name: 'PORT', value: 80 }
10+
]
11+
});
12+
13+
svc.on('install', function () {
14+
console.log('Staring CommandPost service...');
15+
svc.start();
16+
});
17+
18+
svc.on('start', function () {
19+
console.log('Ready');
20+
});
21+
22+
svc.on('error', function (err) {
23+
console.log('Error:', err);
24+
});
25+
26+
console.log('Installing CommandPost service...');
27+
svc.install();

scripts/uninstall-windows-service.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var Service = require('node-windows').Service;
2+
3+
var svc = new Service({
4+
name: 'CommandPost',
5+
script: require('path').join(__dirname, '../app.js')
6+
});
7+
8+
svc.on('uninstall', function(){
9+
console.log('Uninstall complete');
10+
});
11+
12+
svc.on('error', function (err) {
13+
console.log('Error:', err);
14+
});
15+
16+
console.log('Uninstalling CommandPost service...');
17+
svc.uninstall();

0 commit comments

Comments
 (0)