Giter Site home page Giter Site logo

ferozkhan1234 / sim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from varqox/sim-project

0.0 0.0 0.0 14.38 MB

Sim is an open source platform for carrying out algorithmic contests and programming classes

Home Page: https://sim.13lo.pl/

License: MIT License

Makefile 0.71% C++ 70.90% JavaScript 21.45% CSS 5.09% Shell 0.26% Python 0.69% Meson 0.90%

sim's Introduction

Sim Build Status Coverity Scan Build Status Gitter chat

Sim is an open source platform for carrying out algorithmic contests

How to build

You will need meson build system to be installed (on most platforms it is in the meson package).

Dependencies:

  • Meson build system (Debian package: meson)
  • gcc/g++ (with 32 bit support โ€“ for compiling submissions) with C++17 support (Debian package: g++-multilib)
  • MariaDB (Debian package: mariadb-server)
  • MariaDB client library (Debian packages: libmariadbclient-dev)
  • libseccomp (Debian package: libseccomp-dev)
  • libzip (Debian package: libzip-dev)

Debian

sudo apt-get install g++-multilib mariadb-server libmariadbclient-dev libseccomp-dev libzip-dev meson libssl-dev

Ubuntu is not officially supported, you may try it, it may (not) work. Modern versions of some of the above packages are needed to build sim successfully.

Arch Linux

sudo pacman -S gcc mariadb mariadb-libs libseccomp libzip meson && \
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql && \
sudo systemctl enable mariadb && sudo systemctl start mariadb

Instructions: release build and installation step by step

  1. In case you installed MariaDB server for the first time, you should run:
sudo mysql_secure_installation
  1. First of all clone the repository and all its submodules
git clone --recursive https://github.com/varqox/sim && cd sim
  1. Then setup build directory:
meson setup release-build/ -Dbuildtype=release
  1. Build:
ninja -C release-build/
  1. Make sure that you have created a MariaDB account and a database for Sim, use command below to create an user sim@localhost and a database simdb (when asked for password, enter your mariadb root password, by default it is empty โ€“ if that does not work, try running the below command with sudo):
mysql -e "CREATE USER sim@localhost IDENTIFIED BY 'sim'; CREATE DATABASE simdb; GRANT ALL ON simdb.* TO 'sim'@'localhost';" -u root -p
  1. Configure a directory for a Sim instance
meson configure release-build --prefix $PWD/sim

This sets Sim instance's directory to $PWD/sim i.e. subdirectory sim of the current working directory. If you want to install Sim in other location, replace $PWD/sim with it.

  1. Install
meson install -C release-build

It will ask for MariaDB credentials. In previous step you created a MariaDB user and database, by default: username sim, password sim, database simdb and user host localhost.

  1. Run servers If you installed Sim in the default location:
sim/manage start

If you installed Sim elsewhere:

where-you-installed-sim/manage start

You can easily make it run in a background by adding -b parameter:

sim/manage -b start

Meson allows building and installing in one go:

meson install -C release-build

So building, installing and running can be combined into:

meson install -C release-build && sim/manage -b start
  1. Visit http://127.7.7.7:8080 via your web browser. By default a Sim root account was created there with following credentials:
username: sim
password: sim

Remember to change the password now (or later) if you want to make Sim website accessible to others. Do not make hacker's life easier!

  1. Well done! You have just fully set up Sim. There is a sim-server configuration file where-you-installed-sim/sim.conf (sim/sim.conf by default) where server parameters like address, workers etc. reside. Also, there are log files where-you-installed-sim/log/*.log that you can find useful if something didn't work.

  2. If you want to run Sim at system startup then you can use crontab -- just add these lines to your crontab (using command crontab -e):

@reboot sh -c 'until test -e /var/run/mysqld/mysqld.sock; do sleep 0.4; done; where-you-installed-sim/manage start&'

where-you-installed-sim = an absolute path to Sim instance's directory e.g. /home/your_username/sim/sim

  1. Feel free to report any bugs or things you would like to see.

Upgrading

Be aware that sometimes incompatible database or other inner changes won't allow for a smooth upgrade. In such cases sim-upgrader may come handy, grep the commit messages for it to check if it is needed.

To upgrade just type:

git pull --rebase --autostash
git submodule update --init --recursive
meson install -C release-build
sim/manage -b start

Release build

meson setup release-build/ -Dbuildtype=release -Ddefault_library=both
ninja -C release-build/

Development build

meson setup build/ -Dc_args=-DDEBUG -Dcpp_args='-DDEBUG -D_GLIBCXX_DEBUG' -Db_sanitize=undefined -Db_lundef=false
ninja -C build/

Installing

Run after building:

# we will use release-build build directory, if you use other just change all release-build below
meson configure release-build --prefix $PWD/sim # if you want to install to sim/ subdirectory
meson install -C release-build

Managing the Sim instance i.e. starting / stopping servers

For this, there is manage program in the instance`s main directory. To start servers type:

sim/manage start # or other instance's directory

To stop servers:

sim/manage stop

For more options:

sim/manage help

Running tests

ninja -C build/ test # or other build directory

Development build targets

Formating C/C++ sources

To format all sources (clang-format is required):

ninja -C build format

Linting C/C++ sources

All sources

To lint all sources:

ninja -C build tidy

or

./tidy

Specified sources

To lint specified sources:

./tidy path/to/source.cc other/source.h

Static analysis

ninja -C build scan-build

sim's People

Contributors

varqox avatar tonowak avatar maciejczyzewski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.