1

Is it possible to start an application (node server in my case) when it is accessed from a browser with a specified port?

I have a few browser applications on my Raspberry Pi that I use from time to time, and I don't want to always manually start them before use. And at the same time I don't want them constantly running in the background.

Clarification: This question assumes using Raspberry Pi 'headless' and accessing it from a browser over Wi-Fi on another computer.

2

I'd do this by modifying iptables to log activity on that port to a particular file, and use a script to watch the log file and start node.

See this question for a good starting place: https://stackoverflow.com/questions/11584824/run-a-system-command-when-an-iptables-rule-is-matched

1

I would suggest you to use xinetd, which is a lightweight daemon that listens on as many TCP or UDP ports as listed in its configuration. Each port is associated with a process to launch when there's incoming trafic, this trafic being forwarded to the ephemere process.

It is very easy to setup. You might want to start installing it on your system using :

sudo aptitude install xinetd
  • Thanks! Seems like a better solution, I'll give this one a shot and see how it goes. – YemSalat Jun 2 '14 at 18:42
1

Look into systemd.socket. Similar to .service files (which control daemons via the systemctl command and and boot up), .socket files can start a daemon when a request on a socket is detected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.