0

The point of the server is to be able to pick a webcam and stream it, along with a few other things I already have working. I am trying to run a continuous process (mjpg-streamer) from within a node.js server. The node.js server is handling a serving a HTML page that has a select drop down binded to a javascript function to send a command to the server via socket.io. The drop down lets me select video0, video1, and none. However, whenever I try to run the server it refuses saying everything after the a particular block of code is unreachable or the code gets stuck running an infinite process. How can I execute this without locking up the server? Here is the code that causes the problem:

child = exec("video0.sh", function (error, stdout, stderr) {
sys.print('stdout: ' + stdout);
sys.print('stderr: ' + stderr);
if (error !== null) {
  console.log('exec error: ' + error);
}

The bash script video0.sh is:

cd mjpg-streamer/mjpg-streamer ;
export LD_LIBRARY_PATH=. ;
./mjpg_streamer -o "output_http.so -w ./www -p 8080" -i "input_uvc.so -d /dev/video0";
3
  • don't you miss a closing }) there? Commented Feb 6, 2014 at 4:06
  • This may be obvious, but something a lot of people have done(including me). Did you set the sh script to be executable? chmod +x video0.sh? Commented Feb 6, 2014 at 6:20
  • Could you provide any errors? Commented Feb 6, 2014 at 6:22

2 Answers 2

1

you can set a infinite loop in pure shell directly

#!/usr/bin/bash

cd mjpg-streamer/mjpg-streamer ;
export LD_LIBRARY_PATH=. ;
while :
do
  ./mjpg_streamer -o "output_http.so -w ./www -p 8080" -i "input_uvc.so -d /dev/video0";
  sleep 5
done
Sign up to request clarification or add additional context in comments.

Comments

0
child = exec("sh video0.sh", function (error, stdout, stderr) {
  sys.print('stdout: ' + stdout);
  sys.print('stderr: ' + stderr);
  if (error !== null) {
   console.log('exec error: ' + error);
   }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.