Topic: deployment process

i finished the railsguide blog and want it available online so what do you need to store in the web server?the size of the whole blog directory is 30 MB due to the API and vendor folder so i doubt i need to store all the generated contents of rails name_of_project...

Re: deployment process

You need the full application with the full directory structure.

Rails is interpreted not compiled, so in order for the application to run it needs access to all the source code files.
If you want to cut down on the size of the deployment then don't freeze your gems and make sure the correct versions of the gems are running on the server you are deploying to.

If you make use fo capistrano then the whole deployment/update/development life cycle is a breeze by comparison with manually deploying.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

what is ruby DBI (Database independent interface) for?

do i need it?

Re: deployment process

It's an interface for you to use if you want to interrogate/work with your db directly via an api.
no you don't need it.
Most db's have their own and you have ActiveRecord built in to Ruby.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

so the full app means the app, db, public, config and vendor folders if there are plugins?

i'm still finding a tutorial on how to make an web server which monitors temperature (so the input is from sensors) and the data is displayed in graph in my webpage like this one http://www.pachube.com/feeds/2127

i found plugin (http://pullmonkey.com/projects/open_flash_chart) but i do not know how to connect data from the sensor to being displayed in the graph. do i have to learn php for this problem?

Re: deployment process

so the full app means the app, db, public, config and vendor folders if there are plugins?

Pretty much, yes.
If you want to know more about app deployment specifically and RoR in general then you really need to check out railscasts (http://railscasts.com/episodes/133-capistrano-tasks) and grab hold of AWDWR and Programming ruby books from pragprog.comhttp://www.pragprog.com/titles/rails4/agile-web-development-with-rails
http://www.pragprog.com/titles/ruby3/pr … g-ruby-1-9
they'll tell you pretty much everythuing you need to know and are most ruby and Rails programmers bibles

i'm still finding a tutorial on how to make an web server which monitors temperature

you won't find one

but i do not know how to connect data from the sensor to being displayed in the graph. do i have to learn php for this problem?

Now you are scaring me.
writing code to interface with external devices is extremely advanced stuff, I know how advanced it is because I've written code that interfaces with satellite systems, foetal heart monitoring systems, door entry systems and telephony systems.
The very fact that you are asking about php indicates that you are new to programming not just new to RoR and writing an application that has to deal with external devices is way above some experienced programmers never mind new ones.
You have to understand polling techniques used for the device concerned, system resources, error codes and handling and a whole bunch more.

I'm sure given time you'll get it right but don't expect to be able to do this in a couple of months and get it right!

But no. You don't need php.
Anything php can do, Ruby can do and will mostly do it a lot better.

You need to understand the software used in the device you are hooking up to and you need to know how to interact with the ports that the device is using, you'll need to know how to detect which port the device is connected to and whether or not the device is malfunctioning and this is seriously advanced stuff.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

since RoR isnt the go to language for my device (it's php), i'd better stick to php then. the only reason why i used RoR is my adviser said so and it is easy to use,at start.  but for the advanced part, i need php which has an implementation for the device i am to use,arduino (http://www.nuelectronics.com/estore/?p=14).

i asked about the DBI because i thought it may be of use in connecting the database of php to that of a rails app but is it possible?my adviser is of little help and i am all alone in this thesis so I am at your mercy.T_T

Re: deployment process

the language that the device uses is irrelevant to you. What is IMPORTANT is the format that the device outputs and the api that the device supplies in much the same way that when interfacing with web services such as PayPal for example, you don't care what language PayPal uses you just care about how to ue the api.

I don't know your device and I don't know how it connects to your systems, what data storage it has, if it uses bluetooth, usb, serial or something else to communicate with your systems, what api you have available or even what your device actually is which clearly your advisor does know so I would STRONGLY recommend you take your advisers advice.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

arduino has a ruby api available( Ruby Arduino Development). it can connect serially, through bluetooth or wirelessly in the internet (which is what i intend to use). with the ethernet shield, it can be a server or a client (http://arduino.cc/en/Reference/Ethernet) which has a library. 

so what i should do now is to program arduino such that it sends the data in an understandable format to my rails app which will store the data and graph it,right?

Re: deployment process

Well, that sound like a great starting point.
Remember that at the end of the day it's just packets of data and so long as you know what format that data takes you can tell your Rails app what it needs to know and you can verify that the data packets are complete..

From the looks of it you'll probably be working with I/O streams and ruby is incredibly good (necessarily so) at working with those.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

thank you, i will inform you of any developments.

Re: deployment process

hello, i've managed to display the sensor data in a local network using arduino which is programmed as a server (using "processing" language)

include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x0E, 0xC6 };
byte ip[] = { 192, 168, 1, 150};

Server server(3000);

void setup()
{
Ethernet.begin(mac, ip);
server.begin();
}

void loop()
{
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

// output the value of each analog input pin
for (int i = 0; i < 6; i++) {
client.print("analog input ");
client.print(i);
client.print(" is ");
client.print(analogRead(i));
client.println("<br />");
}
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}

i was wondering if you know a ruby command which inserts the sensor data as an entry to a database of rails app which would be in this part i think

client.print("analog input ");
client.print(i);
client.print(" is ");
client.print(analogRead(i));
client.println("<br />");

Last edited by mikedr (2010-11-05 06:07:29)

Re: deployment process

Now you need to create a model which will create the table for you, (I assume you already have the database set up).
the best way to do this is just to scaffold a new model with the fields that you want to store then just update it using the client.print methods you are showing to fill the fields in.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

May I ask what is better, sending data via FTP or 1 entry (to the database of a VPS) at a time per hour?I'm reluctant to change the current setup(latter) since my prof just wants to avoid a million entries in the database but note that the data should be updated per hour.thank you

Re: deployment process

I don't really know enough about your data and where it needs to ultimately reside to make answer you properly but take into account the following when making your decision

1) Transferring data via ftp every hour is not really a problem unless it is a large amount of data per transmission. Handling interrupted transfers and dealing with incomplete packets (packet loss) can be a headache and it WILL happen. At the emd of each ftp upload you will need to verify that each record is complete and re-try the transfer if not.

2) If you have millions of records where are you going to store them if not in a databse?
Millions of records in a database on a vps should not be a problem nowadays.

You could set up a transdaction table to hold unprocessed data in a database, then transmit that data in one chunk at appropriate times then archive the data in a zip file at the same time as clearing it out of the db at appropriate times (so it can be retrieved if necessary)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: deployment process

Thank you very much. now I have confidence to defend my current setup. I, too, don't see a problem if there are a million entries in a database. It's easier to graph the data in the database as I've already done it.

Re: deployment process

Old School db's such as Paradox and Access had huge problems storing large quantities of data,

MySQL, Postgres, Ingres, MSSQL et al all have no such problems but I wouldn't recommend SQLite for anything other than development and testing

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)