We assume you use RVM. If you don't, then replace rvmsudo
with sudo
during the installation process.
For testing environment PhantomJS (at least version 1.8.1) is required by Poltergeist gem to run headless browser tests. See poltergeist for documentation.
Below is a quick summary of the setup procedure. It is followed by detailed instructions for Ubuntu.
The following packages should be installed first: ruby
(and bundler
gem), postgresql
(9.2+), screen
,git
, zip
, unzip
, imagemagick
, xfonts-75dpi
, javac
, java
, ant
, mvn
, gcc
, make
, bc
, libcurl4-openssl-dev
(or some other flavor) and check
. Additionally, tmc-sandbox requires: squashfs-tools
, multistrap
e2fsprogs
, e2tools
and build-essential
.
- Download submodules with
git submodule update --init --recursive
- Install dependencies with
bundle install
- Edit
config/site.yml
, based onconfig/site.defaults.yml
. - Setup PostgreSQL based on
config/database.yml
or configureconfig/database.local.yml
according to your current postgres settings. - Initialize rails database with
rake db:create db:migrate
- Go to
ext/tmc-sandbox
and compile withsudo make
. More information from tmc-sandbox page. - Go to
ext/tmc-sandbox/web
and install dependencies withbundle install
. Compile extensions withrake ext
and run tests withrvmsudo rake test
. - Compile the other stuff in
ext
by doingrake compile
- Install tmc-check by running
rvmsudo make rubygems install clean
inext/tmc-sandbox/uml/output/tmc-check
. - Run the test suite with
rvmsudo rake spec
. - Verify code style with
bundle exec rubocop
.
After you get the test suite to pass see post-install instructions.
We expect the user to be using account which name is tmc.
Update your package list with
$ sudo apt-get update
TMC-server dependencies
$ sudo apt-get install git build-essential zip unzip imagemagick maven make phantomjs bc postgresql postgresql-contrib chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev xfonts-75dpi libpq-dev
Ruby dependencies
$ sudo apt-get install git-core curl zlib1g-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev
RVM dependencies
$ sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
TMC-sandbox dependencies
$ sudo apt-get install squashfs-tools multistrap e2fsprogs e2tools
Install wkhtmltopdf for course certificate generation.
If you want to install the official Oracle JDK, you need to add a ppa repository. You can install Oracle JDK with the following commands
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
❗ If you want to install RVM as a single-user installation, please see RVM installation instructions.
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -L https://get.rvm.io | sudo bash -s stable
$ source /etc/profile.d/rvm.sh
Add yourself to RVM group and install Ruby
$ sudo adduse tmc rvm
Quote from https://rvm.io/support/troubleshooting#sudo
Note: Users must log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time.
Install ruby
$ rvm install 2.2.0
$ rvm use 2.2.0 --default
$ gem install bundler
Run following command and when prompted give tmc as a password, if you want to use another username or stronger password change them into config/database.local.yml.
$ sudo su postgres
$ createuser tmc -s -P
If you cannot run the above command, you can also create the user manually
$ sudo -u postgres
$ psql -c "CREATE USER tmc WITH SUPERUSER CREATEUSER CREATEDB PASSWORD 'tmc';"
❗ Superuser access is useful for dev environment, but discouraged for production.
This is needed for local postgresql installation, as by default the tests are ran as root bc of the sandbox...
Locate the pg_hba.conf file with locate pg_hba.conf
. The file should be located /etc/postgresql//main/pg_hba.conf. You need root privileges to edit the file. Around line 90 change
# "local" is for Unix domain socket connections only
local all all peer
to
# "local" is for Unix domain socket connections only
local all all md5
important run
service postgresql restart
after to implement changes
$ git clone https://github.com/testmycode/tmc-server.git
$ cd tmc-server
$ bundle install
❗ If you are not using a github account, replace the repository submodule URLs with a HTTPS URL in .git/config e.g. https://github.com/testmycode/tmc-langs.git
$ git submodule update --init --recursive
You can view the site settings from the file config/site.defaults.yml
. If you want to change the settings for the site, create a new file config/site.yml
and define the changes there (notice: you do not need to copy the entire file. Settings not in site.yml
will be looked up from site.defaults.yml
).
Initialize the database with rake db:create db:migrate
Note: run rake db:seed
to initialize admin account
$ cd ext/tmc-sandbox
$ sudo make
$ cd web
$ bundle install
$ rake ext
$ rvmsudo rake test
$ cd -
$ rake compile
$ sudo apt-get install check
$ cd tmc-sandbox/uml/output/tmc-check
$ rvmsudo make rubygems install clean
In the tmc-server root directory run
$ rvmsudo rake spec
This might require installation of rubocop; gem install rubocop
.
$ bundle exec rubocop
To enable pghero stats (optional), add the following lines to postgresql.conf
:
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all
Use script/dev_env
to start the server in screen. Please read through the file, if you are interested in the procedure behind starting the service.
In screen, press Ctrl+A
and then a number key to switch between tabs. To stop the dev environment, press Ctrl+C
, wait a bit, then press Q
. Repeat until all tabs are closed.
The default user account is admin
/admin
.
- Recheck your comet server config in
site.yml
and then dorvmsudo rake comet:config:update
. - Install init scripts:
rvmsudo rake comet:init:install
,rvmsudo rake background_daemon:init:install
. - Start the services:
sudo /etc/init.d/tmc-comet start
,sudo /etc/init.d/tmc-background-daemon start
. - If you use Apache, then make sure
public/
andtmp/
are readable and install mod_xsendfile. Configure XSendFilePath to thetmp/cache
directory of the application.
The application should not be deployed into a multithreaded server! It often changes the current working directory, which is a process-specific attribute. Each request should have its process all to itself. If you use Apache with, say, Passenger, then use the prefork MPM.
- Initialize the database with
env RAILS_ENV=production rake db:reset
- Precompile assets with
env RAILS_ENV=production rake assets:precompile
- Run
rvmsudo rake init:install
to install the init script for the submission rerunner. - Do the same in
ext/tmc-sandbox/web
to install the init script for the sandbox.