0

First of all apologies if i couldnt explain my question but i will try my best.

I am building an app which dynamically creates node APIs for users also run them and return url of that API.So, i want to run node server for every Project dynamically.Right now i am using Nodemon which will run a script like this:

 const express = require('express');
 const app = express();
 app.use('/projectone',require('./projects/projectone/server.js'));
 app.use('/projecttwo',require('./projects/projecttwo/server.js'));
 app.listen(3000);

Every new project will add project's link in this script and nodemon will restart automatically.but this is not a good approach as it is restarting all the projects on adding or updating one project.So i want to run separate nodemon or node instance for each project.

Added details

i am using this at my local machine.as it is under development.so when i create new project ,the project generation code adds a project folder with files in projects folder.this change triggers nodemon which restarts and start watching newly added project.

Any suggestion for this will be appreciated.

N.A
  • 855
  • 4
  • 13
  • 34
  • Do you want to use node.js as proxy pass? you want to run different node.js project and run them in the same port and give then the different url in front. like /projectone . /projecttwo – Himanshu sharma Jul 30 '17 at 07:03
  • sorry can you explain the term proxy pass? – N.A Jul 30 '17 at 07:04
  • is this all on one server instance ? When each project is triggered is the url served from the same machine ? – NiallJG Jul 30 '17 at 07:08
  • no i m planning to require port from user.so it will be totally standalone independent API – N.A Jul 30 '17 at 07:08
  • @NiallJG no separate server for all project – N.A Jul 30 '17 at 07:09
  • how are you triggering the deployment on these servers ? Are you asking if you can trigger a deployment on another server from your server using node.js ? – NiallJG Jul 30 '17 at 07:10
  • can you add your server.js code for more understanding? – Himanshu sharma Jul 30 '17 at 07:14
  • if you know the project foldername or filename you can ignore them in nodemon. check out https://github.com/remy/nodemon and https://stackoverflow.com/questions/24120004/nodemon-exclusion-of-files. – Himanshu sharma Jul 30 '17 at 07:49
  • i don't want to ignore any folder as any project can be updated at any time.that's why i want separate instance – N.A Jul 30 '17 at 08:31

0 Answers0