Sim is an open source platform for carrying out algorithmic contests
NOTE: There is a script
scripts/setup_sim_on_debian_12.py. So if you need to look at very precise instructions that set up Sim, you can check out these scripts. If you intend to use it, first look at help, by just running the script without arguments, choose what you need and the script will guide you through the rest.
You will need meson build system to be installed (on most platforms it is in the meson package).
- Meson build system
- gcc/g++ with C++17 support
- MariaDB server
- MariaDB client library
- libseccomp
- libzip
sudo apt install g++ mariadb-server libmariadb-dev libseccomp-dev libzip-dev libcap-dev rustc fpc pkgconf mesonModern versions of some of the above packages are needed to build sim successfully.
sudo pacman -S gcc mariadb mariadb-libs libseccomp libzip libcap rust fpc meson && \
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql && \
sudo systemctl enable mariadb && sudo systemctl start mariadb- In case you installed MariaDB server for the first time, you should run:
sudo mariadb-secure-installation- First of all clone the repository and all its submodules
git clone https://github.com/varqox/sim-project && cd sim-project/subprojects/sim- Then setup build directory:
meson setup release-build/ -Dbuildtype=release- Build:
ninja -C release-build/
- Make sure that you have created a MariaDB account and a database for Sim, use command below to create an user
sim@localhostand a databasesimdb(when asked for password, enter your mariadb root password, by default it is empty – if that does not work, try running the below command withsudo):
sudo mariadb -e "CREATE USER sim@localhost IDENTIFIED BY 'sim'; CREATE DATABASE simdb; GRANT ALL ON simdb.* TO 'sim'@'localhost';"- Configure a directory for a Sim instance
meson configure release-build --prefix $PWD/simThis 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.
- Install
meson install -C release-buildIt 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.
- Run servers If you installed Sim in the default location:
sim/manage startIf you installed Sim elsewhere:
where-you-installed-sim/manage startYou can easily make it run in a background by adding
-bparameter:sim/manage -b startMeson allows building and installing in one go:
meson install -C release-buildSo building, installing and running can be combined into:
meson install -C release-build && sim/manage -b start
- 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!
-
Well done! You have just fully set up Sim. There is a sim-server configuration file
where-you-installed-sim/sim.conf(sim/sim.confby default) where server parameters likeaddress,workersetc. reside. Also, there are log fileswhere-you-installed-sim/log/*.logthat you can find useful if something didn't work. -
If you want to run Sim at system startup then you can use
crontab-- just add these lines to your crontab (using commandcrontab -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
- Feel free to report any bugs or things you would like to see.
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
meson install -C release-build
sim/manage -b startmeson setup release-build/ -Dbuildtype=release -Ddefault_library=both
ninja -C release-build/meson setup build/ -Dc_args=-DDEBUG -Dcpp_args='-DDEBUG -D_GLIBCXX_DEBUG' -Db_sanitize=undefined -Db_lundef=false
ninja -C build/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-buildFor this, there is manage program in the instance's main directory.
To start servers type:
sim/manage -b start # or other instance's directoryTo stop servers:
sim/manage stopFor more options:
sim/manage helpBackups are made using restic. Debin/Ubuntu package: restic, Arch Linux package: restic.
A sim backup can be created with:
sim/bin/backup saveMultiple backups may be created.
To restore a specific backup use the sim/bin/backup restore program. You may want to edit the .db.config file if migrating sim from another machine. To learn more run:
sim/bin/backup helpFirst, naming. Let's call the Sim instance that we want to merge into the main Sim instance and the one we want to merge from the other Sim instance.
In case the merging fails for some reason, make a backup of the main sim instance:
main-sim-instance/bin/backup saveThe other sim instance has to be on the same machine as the main sim instance. If this is not the case, follow the steps below:
- Make a backup of the other instance if not already done:
other-sim-instance/bin/backup save-
Copy the other sim instance to the machine containing the main sim instance, e.g. using
rsync. -
Create user and database for the other sim instance. E.g.
sudo mariadb -e "CREATE USER other_sim@localhost IDENTIFIED BY 'other_sim'; CREATE DATABASE other_simdb; GRANT ALL ON other_simdb.* TO 'other_sim'@'localhost';"-
Edit file
other-sim-instance/.db.configto use the new user and database. -
Restore the other sim instance from latest backup:
other-sim-instance/bin/backup restore latestNow we have both instances on the same machine we can merge them. To do so, run:
main-sim-instance/bin/sim-merger path-to-other-sim-instanceThen restore the main instance:
main-sim-instance/manage start -bLastly, you can remove the other sim instance by removing files and database used, e.g.
rm -rf other-sim-instance/
sudo mariadb -e "DROP DATABASE other_sim; DROP USER other_sim@localhost;"ninja -C build/ test # or other build directoryTo format all sources (clang-format is required):
ninja -C build formatTo lint all sources:
ninja -C build tidyor
./tidyTo lint specified sources:
./tidy path/to/source.cc other/source.hninja -C build scan-build