The fileserver is a simple frontend to a disk storage space that contains
auxiliary files for assignments, files submitted by users and evaluation
results. For a description of the communication protocol used by the frontend
and workers, see the [Communication](#communication) chapter
results.
For a description of the communication protocol used by the frontend
and workers, see the [Communication](#communication) chapter.
## Description
The storage is implemented in Python, using the Flask web framework. This
particular implementation evolved from a simple mock fileserver we used in early
stages of development.
stages of development. It prooved to be very reliable, so we decided to keep fileserver
as separate component instead of integrating this functionality into main API.
### Internal storage structure
Fileserver stores its data in a configurable filesystem folder. This folder has
the following subfolders:
- `./submissions/<id>` - folders that contain files submitted by users
- `./submissions/<id>` -- folders that contain files submitted by users
(student's solutions to assignments). `<id>` is an identifier received from
the ReCodEx API.
- `./submission_archives/<id>.zip` - ZIP archives of all submissions. These are
- `./submission_archives/<id>.zip` -- ZIP archives of all submissions. These are
created automatically when a submission is uploaded. `<id>` is an identifier
of the corresponding submission.
- `./tasks/<subkey>/<key>` - supplementary task files (e.g. test inputs and
- `./tasks/<subkey>/<key>` -- supplementary task files (e.g. test inputs and
outputs). `<key>` is a hash of the file content (sha-1 is used) and `<subkey>`
is its first letter (this is an attempt to prevent creating a flat directory
structure).
## Installation
To install and use the fileserver, it's necessary to have Python and Pip
installed.
## Installation
1. Clone this repository
2. Install dependencies using `pip`
To install and use the fileserver, it's necessary to have Python3 with `pip` package manager installed. It's needed to install the dependencies. From clonned repository run the following command:
```
pip install -r requirements.txt
$ pip install -r requirements.txt
```
That's it. Fileserver doesn't need any special installation. It's possible to build and install _rpm_ package or install it without packaging the same way as monitor, but it's only optional. The installation would provide you with script `recodex-fileserver` in you `PATH`. No systemd unit files are provided, because of the configuration and usage of fileserver component is much different to our other Python parts.
## Configuration and usage
There are several ways of running the ReCodEx fileserver. We'll cover two
@ -47,32 +51,62 @@ typical use cases.
### Running in development mode
For simple development usage, it's possible to run the fileserver in the command
- **port** -- port where the fileserver should listen
- **working_directory** -- directory where the files should be stored
- **htpasswd** -- path to user file fot HTTP Basic Authentication
- **user** -- user under which the server should be run
### Running using uWSGI
Another option is to run fileserver as a standalone app via uWSGI service. Setup is also quite simple, configuration file can be also generated by `mkconfig.py` script.
1. (Optional) Create a user for running the fileserver
2. Make sure that your user can access your clone of the repository
3. Run `python mkconfig/mkconfig.py uwsgi --port PORT --user YOUR_USER