I'm trying whole day to find some solution how to run two scripts written in nodejs parallel in docker.
I've two files: app/index.js - express app using port 8080 app/rabbit.js - script is connection to rabbitmq only as consumer and processing messages
I'm trying to use gulp and nodemon ( I've found solution on the stackoverflow, but id doesn't work )
var gulp = require('gulp')
var gulputil = require('gulp-util');
var child_process = require('child_process');
var nodemon = require('gulp-nodemon');
var processes = {server1: null, server2: null};
gulp.task('start:server', function (cb) {
processes.server1 = nodemon({
script: "app/index.js",
ext: "js"
});
processes.server2 = nodemon({
script: "app/rabbit.js",
ext: "js"
});
cb(); // For parallel execution accept a callback.
// For further info see "Async task support" section here:
// https://github.com/gulpjs/gulp/blob/master/docs/API.md
});
process.on('exit', function () {
// In case the gulp process is closed (e.g. by pressing [CTRL + C]) stop both processes
processes.server1.kill();
processes.server2.kill();
});
gulp.task('run', ['start:server']);
gulp.task('default', ['run']);
This is always runs second script "app/rabbit.js" twice. I'm open to any solution, but I need to run two nodejs script at once in one docker instance.
Any Ideas? Thanks in advance!
For anyone who will have same problem, I've found solution.
Step 1:
Step 2:
Step 3:
Step 4:
Step 5: