1

I'm trying to run grunt with a js script. The script start up a server that should be listening all the time in background. To it I'm using grunt and grunt-exec, and my exec.js is like that

start: {
        cmd: function () {
            var start = 'node server.js &';
            console.info('Starting');
            return start;
        }
    }

When I run grunt exec:start the process finish but the server is not running.

Same command without '&' works but it's not the wanted.

I've tried to move the command to a bash but the result is the same, the server is never started when the character '&' is added, neither in the .sh nor in the grunt-exec command.

Scipion
  • 1,350
  • 1
  • 10
  • 16

1 Answers1

0

Finally I solved it changing the command:

var start = "nohup node server.js";

I.t seems run in background properly.

Scipion
  • 1,350
  • 1
  • 10
  • 16