Try moving the following line:

var express = require('express');

Down to after the `service.run()` call:

var express = require('express');

setInterval (function () {
   console.log (new Date ().toString ());
}, 1000);

Steve

On Sunday, 11 October 2015 05:37:23 UTC+1, Matthias Bleyl wrote:
>
> Here is my code:
>
> process.chdir(__dirname);
>
> var service = require ("os-service");
> var express = require('express');
> var fs = require ("fs");
>
> var serviceName = "myService";
> switch (process.argv[2])
> {
>  case ("--add"):
>     service.add (serviceName, {programArgs: ["--run"]}, function(error){ 
>        if (error)console.warn(error); else console.log(serviceName+" 
> added");
>     });
>     break;
>  case ("--remove"):
>     service.remove (serviceName, function(error){ 
>        if (error)console.warn(error); else console.log(serviceName+" 
> removed");
>     });
>     break;
>  case ("--run"):
> var logStream = fs.createWriteStream (serviceName + ".log"); 
>  service.run (logStream, function () {
>         service.stop (0);
>     });
>  // appliation code
>  setInterval (function () {
>  console.log (new Date ().toString ());
>  }, 1000);
>  break;
> }
>
>
> ---------------------------------------------------------------
>
> All works fine from console (in Windows): --add, --remove, --run  .. no 
> problem at all.
> However, starting the added service from the Windows service manager 
> fails, unfortunately!
> To get it running as a service, I have to remove the line "var express = 
> require('express');"
> Something does not work together between express and os-service?
> Express was installed using "npm install express".
>
> Matthias 
>  
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/94ea42ac-8c07-4f70-ac75-0f8d0ef2cb23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to