Installing Grader Web Interface

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
Return to ฐานความรู้

The aim of this document is to set up the grader's web interface rails application so that users can access it via http://your-web-server/grader. The application uses mongrel_cluster as its load balancer.

Install HAML

The grader makes use of HAML. So you need to install it first.

gem install haml --no-ri

Check out the Grader Web Interface

First, make a directory that will contain all the grader files. In my case, I make a directory called "grader" inside my home directory.

mkdir ~/grader

Inside the directory, you check out the web interface.

svn co http://theory.cpe.ku.ac.th/grader/web/tags/0.1 ~/grader/web

Set up the Database

cd ~/grader/web/config
cp database.yml.SAMPLE database.yml

Then, edit database.yml so that it reflects the database setting of your machine.

Note: In Ubuntu, the database socket is not located at /tmp/mysql.sock as it is in other distributions. You need to add one extra line in database.yml to tell rails this:

 adapter: mysql
 socket: /var/run/mysqld/mysqld.sock
 database: ioi
 username: ioi
 password: whateverpassword
 host: localhost

Next, you do the migration:

cd ~/grader/web
rake db:migrate

Check your MySQL to see if the tables actually appear.

Test the Grader for the First Time

Then, run the server

ruby script/server

Go check http://localhost:3000. You can login as root and the password is ioionrails. You should change the password immediately and logout.

Set up Mongrel Cluster

We assume that you already have mongrel_cluster installed in your system.

Have mongrel create a config file for you:

mongrel_rails cluster::config -e production -p 5000 -a 127.0.0.1 -N 2 -c ~/grader/web

The config file is located at ~/grader/web/config/mongrel_cluster.yml. It should look like this:

--- 
cwd: /home/ioi/grader/web
log_file: log/mongrel.log
port: "5000"
environment: production
address: 127.0.0.1
pid_file: tmp/pids/mongrel.pid
servers: 2

Next, start the server.

cd /~grader/web
mongrel_rails cluster::start

See if it works by checking out http://localhost:5000/.

Connect mongrel_cluster with apache2

First, we make the grader application as one of the available sites.

cd /etc/apache2/sites-available
sudo emacs grader