- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My webserver is running very slow
here is my code!
/**** indicate if Relays are on or off ****/
var relay_1_status = "off";
var relay_2_status = "off";
var relay_3_status = "off";
var relay_4_status = "off";
var system = require('child_process').exec;
var mraa = require('mraa');
/*
* About controlling galileo with a webpage
*/
function startServer()
{
console.log("Loading..");
var R1 = new mraa.Gpio(2);
var R2 = new mraa.Gpio(3);
var R3 = new mraa.Gpio(4);
var R4 = new mraa.Gpio(5);
R1.dir(mraa.DIR_OUT);
R2.dir(mraa.DIR_OUT);
R3.dir(mraa.DIR_OUT);
R4.dir(mraa.DIR_OUT);
console.log("Starting web controller...");
var http = require('http');
http.createServer(function (req, res) {
function respond() {
res.writeHead(200, { "Content-Type": "text/html" });
res.write("<!DOCTYPE html>");
res.write("OstaLab Final Project");
res.write("
Switches Status :");
res.write(relay_1_status);
res.write(relay_2_status);
res.write(relay_3_status);
res.write(relay_4_status);
res.write("
Control your sweet home ^_^ :
");res.write("
");res.write("
");res.write("
");res.write("
");res.write("
");res.write("
");res.write("
");res.write("
");res.write("");
res.end();
}
console.log("Request: " + req.url);
// Control L Switch 1
if(req.url === "/S1On") {
R1.write(0);
relay_1_status = "on";
console.log("pin 2 on");
}
if(req.url === "/S1Off") {
R1.write(1);
relay_1_status = "off";
console.log("pin 2 off");
}
// Control L Swtich 2
if(req.url === "/S2On") {
R2.write(0);
relay_2_status = "on";
console.log("pin 3 on");
}
if(req.url === "/S2Off") {
R2.write(1);
relay_2_status = "off";
console.log("pin 3 off");
}
// Control L Swtich 3
if(req.url === "/S3On") {
R3.write(0);
relay_3_status = "on";
console.log("pin 4 on");
}
if(req.url === "/S3Off") {
R3.write(1);
relay_3_status = "off";
console.log("pin 4 off");
}
// Control L Swtich 4
if(req.url === "/S4On") {
R4.write(0);
relay_4_status = "on";
console.log("pin 5 on");
}
if(req.url === "/S4Off") {
R4.write(1);
relay_4_status = "off";
console.log("pin 5 off");
}
respond();
}).listen(1337);
console.log('Server running at http://your_board_IP:1337/'); http://your_board_IP:1337/');
}
/*
* What we want to run
*/
console.log("Starting server");
startServer();
Any Suggestions ??
- Tags:
- Intel® Makers
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hathout,
Do you have an estimated time for the delays in your application?
What is the output of running uname –a?
Are you just running this application in your board?
Are you sure this is not an issue with the network itself?
I suggest you to debug your code to check the delays you are getting between the requests to the server. You can also try to edit your code in order to be modular and not a sequence
Regards,
Charlie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hathout,
Do you have updates in this?
Have you been able to debug your code?
Regards,
Charlie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page