My Code is getting stuck in this function. It goes into a chain of callbacks. Could someone please guide me through it?
router.get('/search',function(req, res, next){
//Check/Convert the selected query to MPEG
//Color_Analysis.py -d path/to/query -c 1 :- outputs a file with 150 lines & Avg.py
//back.py -d path/to/query :- will generate file with 8/10 lines.
//Audio.py index_number_of_query :- will output a vector of weights
//Combine all outputs and display the frame.
console.log("I entered-1 :(");
queryPath = "/home/akshay/Desktop/576_Pro/MediaServer/public/dataset/query";
queryFolder = queryPath+'/'+req.param('query');
console.log(queryFolder);
console.log("I entered-2 :(");
// exec("ba(sh ~/Desktop/576_Pro/MediaServer/public/run_project.sh",function(err, stdout, stderr){
console.log("I entered-3 :(");
exec("bash ~/Desktop/576_Pro/MediaServer/public/run_project.sh "+queryFolder,function(error, stdout, stderr){
if(error){
console.log('Akshay');
console.log('error'+error);
return;
}
console.log("Error "+stderr+" stdout "+stdout);
res.writeHead(302, {'Location': '/results'});
res.end();
});
I don't have any idea but I just want to know if my bash file isn't making the node.js callback. This is the run_project.sh bash file which is being included in the code above:
#!/bin/sh
echo "In Bash"
cd '/home/akshay/Desktop/576_Pro/MediaServer/public/python/'
echo "Convert query to mp4"
#./run_project2.sh $1
#python createpng.py -d $1 > supress.txt
echo "Converted to mp4"
echo "Started Color"
python color/Color_analysis.py -d $1 -c 1 > ../descriptors/color_temp.txt
python color/color_out.py ../descriptors/color_temp.txt > ../descriptors/color.txt
python color/color_result.py ../descriptors/color_temp.txt > ../descriptors/frame_info.txt
python color/color_graph.py ../descriptors/color_temp.txt > ../descriptors/graph_info.txt
echo "Finished Color"
# python color/color_check.py query_color.txt > color_out
echo "Started Audio"
python audio/Audio_Init.py
python audio/Audio.py $1 > ../descriptors/audio.txt
echo 'Finished Executing'
echo 'Started Motion'
python motion/back.py -d $1 > ../descriptors/video_desc_temp.txt
python motion/optical_check.py -d '/home/akshay/Desktop/576_Pro/MediaServer/public/descriptors/motion' -q ../descriptors/video_desc_temp.txt > ../descriptors/motion.txt
echo 'Finished Video'
I have tested the bash script prior to integrating it in the node.js and have faced no issues regarding it. It runs pretty much fine except for the fact that it takes about 5 min for the fact that the python files executing above are pretty heavy and they take a lot of time. But other then that all seems to work pretty much ok.