diff --git a/.gitignore b/.gitignore index 4ef0b67..cb8b3c1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .DS_Store/ npm-debug.log node_modules/ +example/daemon/ diff --git a/README.md b/README.md index f8f9137..b610efa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/winsw/x64/winsw.exe b/bin/winsw/x64/winsw.exe index 6267ef2..dde94fb 100644 Binary files a/bin/winsw/x64/winsw.exe and b/bin/winsw/x64/winsw.exe differ diff --git a/example/helloworld.js b/example/helloworld.js index 65cfc15..ee1b23c 100644 --- a/example/helloworld.js +++ b/example/helloworld.js @@ -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'); @@ -12,4 +11,4 @@ console.log('Server running at http://127.0.0.1:3000/'); /*setTimeout(function(){ process.exit(); },15000); -*/ \ No newline at end of file +*/ diff --git a/example/install.js b/example/install.js index 006d026..866954a 100644 --- a/example/install.js +++ b/example/install.js @@ -8,6 +8,11 @@ var svc = new Service({ env:{ name: "NODE_ENV", value: "production" + }, + serviceAccount:{ + domain:'domain', + user:'username', + password:'password' } }); diff --git a/lib/daemon.js b/lib/daemon.js index f08de1e..c710b0d 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -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 }); } }, diff --git a/lib/winsw.js b/lib/winsw.js index 2c58534..106e348 100644 --- a/lib/winsw.js +++ b/lib/winsw.js @@ -64,6 +64,15 @@ module.exports = { }); } + // Optionally add service account + if(config.serviceAccount){ + xml += ''; + xml += config.serviceAccount.domain? '' + config.serviceAccount.domain + '' : ''; + xml += '' + config.serviceAccount.user + '' + + '' + config.serviceAccount.password + '' + + 'true'; + } + xml += ""; return xml;