4

In my project am trying to run nodejs script from ruby on rails.

Am running in my product_details_controller like this:

system "node /home/user1/sample.js"

In sample.js am doing like this:

var jsdom = require('/usr/local/lib/node_modules/jsdom'),
    request = require('/usr/local/lib/node_modules/request');
var _mysql = require('/usr/local/lib/node_modules/mysql');
var MYSQL_USER = 'root';
var MYSQL_PASS = 'abc';
var DATABASE = 'example';
var mysql = _mysql.createClient({
    user: MYSQL_USER,
    password: MYSQL_PASS,
});
mysql.query('USE ' + DATABASE);
mysql.query('select * from product_details',
    function selectCb(err, results, fields) {
        if (err) throw err;
        else {
            for (var i in results) {
                var product = results[i];
                console.log(product);
            }
        }
    }); 

In development mode it is working fine. But when am trying deploy it in server am facing problem.

mysql.query('use '+DATABASE) is not executing and it is looping there only. I don't know how fix this. Please help. In errorlog am not getting errors also. Am not getting any errors and any response also. Please help me. Thanks in advance.

1

0

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.