Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store/
npm-debug.log
node_modules/
example/daemon/
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ var svc = new Service({
});
```

### Setting the Service Account
The user account under which the service executes can be specified in the config as shown below:

```js
// Create a new service object
var svc = new Service({
name:'Hello World',
description: 'The nodejs.org example web server.',
script: 'C:\\path\\to\\helloworld.js',
serviceAccount:{
domain:'domain',
user:'username',
password:'password'
}
});
```

### User Account Attributes

Expand Down
Binary file modified bin/winsw/x64/winsw.exe
Binary file not shown.
5 changes: 2 additions & 3 deletions example/helloworld.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
//res.end(JSON.stringify(process.env));
res.end('Hello World\n');
res.end('hello from ' + process.env['USERNAME']);
});

server.listen(3000, '127.0.0.1');
Expand All @@ -12,4 +11,4 @@ console.log('Server running at http://127.0.0.1:3000/');
/*setTimeout(function(){
process.exit();
},15000);
*/
*/
5 changes: 5 additions & 0 deletions example/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ var svc = new Service({
env:{
name: "NODE_ENV",
value: "production"
},
serviceAccount:{
domain:'domain',
user:'username',
password:'password'
}
});

Expand Down
3 changes: 2 additions & 1 deletion lib/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ var daemon = function(config){
logpath: this.logpath,
env: config.env,
flags: config.flags,
execPath: this.execPath
execPath: this.execPath,
serviceAccount: config.serviceAccount
});
}
},
Expand Down
9 changes: 9 additions & 0 deletions lib/winsw.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ module.exports = {
});
}

// Optionally add service account
if(config.serviceAccount){
xml += '<serviceaccount>';
xml += config.serviceAccount.domain? '<domain>' + config.serviceAccount.domain + '</domain>' : '';
xml += '<user>' + config.serviceAccount.user + '</user>'
+ '<password>' + config.serviceAccount.password + '</password>'
+ '<allowservicelogon>true</allowservicelogon></serviceaccount>';
}

xml += "</service>";

return xml;
Expand Down