vendredi 27 mars 2015

Running a backend server with node.js

I am trying to run a Django backend with node. The objective is to create a task with jake which will run a django server and the protractor tests to use on a CI server.


If I understand the process documentation, I need a child process, I an trying to create that process with:



var spawn = require('child_process').spawn,

// django contains the abpath to the manage.py which starts the server
backend = spawn('python', [django, 'runserver', '8001']);

backend.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});

backend.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});

backend.on('close', function (code) {
console.log('child process exited with code ' + code);
});

backend.stdin.end();


Running a command like 'ls' works well, but how can I run a background process?


This way it is not closing the backend process at the end.


Closing automatically the backend server at the end of the command is a must.


Aucun commentaire:

Enregistrer un commentaire