ผลต่างระหว่างรุ่นของ "ฐานความรู้"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
 
(ไม่แสดง 17 รุ่นระหว่างกลางโดยผู้ใช้ 2 คน)
แถว 25: แถว 25:
  
 
== Rails Deployment with Mongrel on Ubuntu Guide ==
 
== Rails Deployment with Mongrel on Ubuntu Guide ==
 +
This guide plagiarizes Punneng's [http://weblog.punneng.com/2007/5/5/rails-deployment-ubuntu-apache-subversion-mongrel-capistrano Rail::Deployment (Ubuntu - Apache - Subversion - Mongrel - Capistrano)] article.
 +
 +
This guide assumes that you already have rails installed.
 +
 
=== Create a New User ===
 
=== Create a New User ===
 
For each one application, you should create a new user for exclusive use by the application. Put the user in the '''<tt>www-data</tt>''' group.
 
For each one application, you should create a new user for exclusive use by the application. Put the user in the '''<tt>www-data</tt>''' group.
 
  useradd username
 
  useradd username
 
  usermod -g www-data username
 
  usermod -g www-data username
 +
Edit '''<tt>/etc/sudoers</tt>''' and add:
 +
username ALL = (ALL) ALL
  
== Installing Grader Web Interface ==
+
=== Install Mongrel and Mongrel Cluster ===
=== Installing HAML ===
+
  sudo gem install daemons mongrel mongrel_cluster
The grader makes use of HAML. So you need to install it first.
 
  gem install haml --no-ri
 
  
=== Checking out the Grader Web Interface ===
+
=== Install Your Rails Application Somewhere ===
First, make a directory that will contain all the grader files. In my case, I make a directory called "grader" inside my home directory.
+
Well, this step is totally up to you.
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
 
  
=== Setting up the Database ===
+
== Design and Specification of the Lower-Level Grading System ==
cd ~/grader/web/config
+
: ''See [[An Online Programming Judge System]]''
cp database.yml.SAMPLE database.yml
 
Then, edit '''<tt>database.yml</tt>''' so that it reflects the database setting of your machine.
 
  
'''Note:''' In Ubuntu, the database socket is not located at '''<tt>/tmp/mysql.sock</tt>''' as it is in other distributions. You need to add one extra line in database.yml to tell rails this:
+
== Installing Grader Web Interface ==
  adapter: mysql
+
: ''See [[Installing Grader Web Interface]]''
  '''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 '''<tt>http://localhost:3000</tt>'''. You can login as '''<tt>root</tt>''' and the password is '''<tt>ioionrails</tt>'''. You should change the password immediately and logout.
 
  
 
==Judge==
 
==Judge==
Judge system reads user submissions and test submissions and grades.  It can be run with different configurations (called "environments") depending on the situations, e.g., during the exam, the judge probably grades with example test cases but while grading it grades with different sets of test cases.  This multiple configurations can be done with multiple "environments" where configured so that the judge finds different sets of test data.
+
: ''see main article [[Installing and configuring Judge]]''
 
+
== Resetting MySQL Root Password ==
===Basic directory structure===
+
This HOWTO is copied from [http://www.debian-administration.org/articles/442 here].
/[judge-root]
+
First, stop your database.
  /ev                    (containing grading information for each problem)
+
/etc/init.d/mysql stop
    /problem_1
+
Then, start up the database in the background.
      ...
+
  /usr/bin/mysqld_safe --skip-grant-tables &
    /problem_n
+
You can now log in to MySQL without a password.
    /test_request        (containing TEST interface template for each problem)
+
mysql --user=root mysql
      /problem_1
+
And you can set a new password with the following two commands:
      ...
+
  mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
      /problem_n
+
mysql> flush privileges;
  /result                (containing grading results)
+
Once you're done with that, leave MySQL, and bring the server back up to the foreground.
    /user_1
+
  fg
      /problem_1
+
Kill the server with Ctrl-C. And restart the server again.
        /submission_1   
+
/etc/init.d/mysql start
    ...
 
    /user_n
 
  /scripts                (where all script are)
 
    /config              (where all config files are)
 
    /lib       
 
    /std-script          (grading scripts)
 
    /templates            (used for importing scripts)
 
    /test
 
  /log
 
 
 
===Judge environments===
 
Currently there are 3 environments: '''exam''', '''grading''', and '''test'''.  Only the first two are relevant to normal usage.  The test environment is only used when the system runs its unit test scripts.
 
 
 
The main different between the exam environment and grading environment, other than having different locations for test cases, is on how the outputs from the grading are shown to the user. In the exam environment, the system is configured so that it only reports 'passed' or 'failed', but in grading environment, each result for each test case is shown.
 
 
 
===How to install===
 
====Check out the scripts directory from the SVN====
 
====Edit config files====
 
Config files are in <tt>(judge-home)/scripts/config</tt>. In that, you will find sample config files (under <tt>*.SAMPLE</tt>). 
 
 
 
* First you have to copy and edit <tt>environment.rb</tt>.
 
** '''<tt>RAILS_ROOT</tt>''' --- The judge accesses submissions through Rails ActiveRecord; therefore, it has to run Rails' environment.  You should set <tt>RAILS_ROOT</tt> to point to where the root of Rails application for the web interface is.  (There is a drawback for this design: you have to install and configure the web interface even when you just want to run the judge system.)
 
** '''<tt>GRADER_ROOT</tt>''' --- This is the directory where the scripts are. It should be <tt>(judge-home)/scripts/config</tt>.  ('''Notes:''' This should actually read JUDGE_SCRIPT_ROOT, will fix it later ---[[ผู้ใช้:Jittat|Jittat]] 17:35, 16 มีนาคม 2008 (ICT))
 
 
 
* For each environment, you'll have to edit its configuration.  The configuration file for environment <tt>(ENV)</tt> is <tt>env_(ENV).rb</tt>.  Most configuration should work as it is, (''except that current both grading environment and exam environment are configured to share the same <tt>ev</tt> directory'').  You configure the system by modifying Ruby commands running inside a <tt>Grader::Initializer.run do |config| ... end</tt> block.  For each configuration parameter, you set the attribute of the <tt>config</tt> variable.
 
** Basic attributes
 
*** <tt>config.problems_dir</tt> --- This is where test data are. Usually it is <tt>(judge-home)/ev</tt>, but you may want to configure this differently for ''exam'' and ''grading'' environments.
 
*** <tt>config.user_result_dir</tt> --- This is where the grading results are stored.  Again, as in <tt>problem_dir</tt>, you may want to set it differently for different environments.
 
** Other attributes (shall be documented later --- [[ผู้ใช้:Jittat|Jittat]] 18:03, 16 มีนาคม 2008 (ICT))
 
*** Locations
 
**** <tt>config.problems_dir</tt>
 
**** <tt>config.user_result_dir</tt>
 
**** <tt>config.test_request_input_base_dir</tt>
 
**** <tt>config.test_request_output_base_dir</tt>
 
**** <tt>config.test_request_problem_templates_dir</tt>
 
*** Logging and reporting status of the judge
 
**** <tt>config.talkative</tt>
 
**** <tt>config.logging</tt>
 
**** <tt>config.log_dir</tt>
 
**** <tt>config.report_grader</tt>
 
*** Reporting result
 
**** <tt>config.comment_report_style</tt>
 

รุ่นแก้ไขปัจจุบันเมื่อ 09:28, 5 สิงหาคม 2551

Apache2 on Ubuntu

Enabling User Directory

This is how to set up Apache2 on Ubuntu so that, when hxxp://server/~username is accessed, the browser returns the content in /home/username/public_html.

First, user directory is now a mod in Ubuntu's apache2. If you have not installed the mod, then execute the following command:

sudo a2enmod userdir

Second, edit /etc/apache2/apache2.conf and add the following lines:

<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>

Third, execute the following command:

cd /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/userdir.conf userdir.conf
sudo ln -s /etc/apache2/mods-available/userdir.load userdir.load

Forth, restart your apache2:

sudo /etc/init.d/apache2 restart

Rails Deployment with Mongrel on Ubuntu Guide

This guide plagiarizes Punneng's Rail::Deployment (Ubuntu - Apache - Subversion - Mongrel - Capistrano) article.

This guide assumes that you already have rails installed.

Create a New User

For each one application, you should create a new user for exclusive use by the application. Put the user in the www-data group.

useradd username
usermod -g www-data username

Edit /etc/sudoers and add:

username ALL = (ALL) ALL

Install Mongrel and Mongrel Cluster

sudo gem install daemons mongrel mongrel_cluster

Install Your Rails Application Somewhere

Well, this step is totally up to you.

Design and Specification of the Lower-Level Grading System

See An Online Programming Judge System

Installing Grader Web Interface

See Installing Grader Web Interface

Judge

see main article Installing and configuring Judge

Resetting MySQL Root Password

This HOWTO is copied from here. First, stop your database.

/etc/init.d/mysql stop

Then, start up the database in the background.

/usr/bin/mysqld_safe --skip-grant-tables &

You can now log in to MySQL without a password.

mysql --user=root mysql

And you can set a new password with the following two commands:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
mysql> flush privileges;

Once you're done with that, leave MySQL, and bring the server back up to the foreground.

fg

Kill the server with Ctrl-C. And restart the server again.

/etc/init.d/mysql start