leeand00
leeand00

Reputation: 26402

Using NGINX to kick off a process when a URL is requested?

Assuming the process isn't running to begin with; is it possible to kick off a process when a URL is visited by a browser for the first time, and then make sure that the browser is forwarded to the same requested URL (which now has a running process...)?

The reason I ask is that I have a server-side wiki written in node.js that I would like to run many instances of, but it is running on a server with very limited resources (a Raspberry pi), and I'm afraid if I kick off all the wiki processses at once I'll run out of memory for them to run in.

I'm also planning on eventually have a cron job that checks to see if they have been used and shut them down.

Upvotes: 1

Views: 121

Answers (1)

Brad
Brad

Reputation: 163448

Back in the day, most web servers would support CGI, which basically just sends the request data to a script and takes the response and sends it back to the client. Nginx does not support CGI directly, but it does support FastCGI and someone has made some code to do what you want, effectively wrapping CGI with FastCGI.

However, I think you're asking the wrong question. Your actual application is running in Node.js. Why would you like to run many instances of it? Starting them all at once or staggered will not likely make any difference in your memory usage. They are going to take memory when running, no matter when you started them. Consider that you probably only need one of these instances.

Upvotes: 1

Related Questions