A server shell for you to play with Powered by Django + Nginx + Postgres + Bootstrap + Celery.

Overview

Template server

A server shell for you to play with

Powered by Django + Nginx + Postgres + Bootstrap + Celery.


Getting started

  1. Install Docker Community Edition
  2. Install docker-compose into python3, e.g. pip3 install --user docker-compose
  3. Add your user to the docker group. sudo usermod -a -G docker username ; you may have to reboot after this step for you to show up in the group.
  4. Create a file .local_params in the root directory using .local_params_examples as a template. Read section "Running jobs" for the details.

You should then use the local-docker-compose script as a drop in replacement for docker-compose. For example, to start the server you can run local-docker-compose up --build.

Cleaning up after docker for a clean rebuild:

  1. ./cluspro-docker-compose rm will remove the containers
  2. docker volume prune

If you don't explicitly remove the volumes between docker runs, the databases persist, so you can stop the containers and launch them again safely without any loss of data.

Architecture

Docker runs several services: web (which runs Gunicorn), nginx, db (Postgres database). Gunicorn handles the python (Django) code, accesses the database and cooperates with Nginx. Celery is a background task manager and it need rabbitMQ to run (message broker). Flower is a task monitor, which is powered by Celery. It can be accessed at localhost:5555

Structure

All the frontend code is located in server/. The structure of server/ directory is enforced by the Django rules, so we have server/server, where all the server settings are located (settings.py) as well as config.py. config.py is where the custom variables are kept (e.g. email login and password for sending messages to the user), which in turn are populated from the environment, which is set in docker-compose.yml.
core/ contains the app code, as it's called in Django. core/templates has all the html files, core/static - CSS and JS, and runner/ contains the code for job running.

Core/ structure

  1. views.py is the main file - it has functions, which render the pages and handle all the forms and requests. Most of functions return an HTML response.

  2. urls.py assigns URLs to the functions in views.py.

  3. models.py contains custom data tables, which are added to the default Django tables. Right now it contains a model for jobs, which can be customized as you wish. The intention, however, was to keep all the generic job fields as separate class attributes (job name, IP etc.) and to store all the rest job specific parameters as a json string in details_json field. This way we can prevent creating many different tables for different job types or addition of infinite new fields to the same job table (once we add new job parameters, for example).

  4. All the forms on the website are contained in forms.py and it should be kept so. These forms are all handled in views.py.

  5. emails.py has messages for users, whenever we want to send them something. They use the e-mail address and password specified in server/settings.py, which are in turn taken from environmental variables in docker-compose.yml. If they were not specified you will get an error, whenever the server is trying to send a message.

  6. env.py is where you should keep your local variables. Also all the variables in env dictionary will be passed as a context to the html templates, so you can refer to them in the templates.

At the first launch

Two users are created.

  1. admin with password 'admin'. This is a superuser, you should change the password for it immediately. The admin page is located at http://localhost:8080/admin
  2. anon, which is where you log in once you click 'use without your own account' button on the login page. It has limited permissions.

Also storage/ directory is created in the root, where all the jobs will be kept.

Jobs

When you run jobs they are stored in docker container in /storage, which is by default mounted in your project root. You can change this in docker-compose.yml. Storage has two directories: tmp/ for temporary storage, if you need to compute or check something before adding the job to the database, and jobs/ with all the jobs.


Running jobs

Jobs

Currently a job performs addition of two integer numbers. Some additional requirements are added to demonstrate how to use error pop-ups etc. The task itself is located in models.py.

.local_params

Environmental variables with some paths, e-mail login and password are stored in .local_params, which are used when you run local-docker-compose. To create the file use .local_params_example as a template.

Variables for sending e-mails. If you don't specify them, everything will still run, but you will get errors when new users register etc. If your e-mail is [email protected] and the password is password then the values should be:

EMAIL_USER - server
EMAIL_PASS - password
EMAIL_HOST - smtp.gmail.com

RABBITMQ_USER and RABBITMQ_PASS will be generated and added to .local_params at the first run of local-docker-compose, unless specified by the user.

LOCAL_PORT is the port, through which you access the server (default is 8080)

SECRET_KEY is for Django internal use (is generated at the first run of local-docker-compose) and should be kept secret.

Owner
Mengting Song
Mengting Song
Ningyu Jia(nj2459)/Mengyin Ma(mm5937) Call Analysis group project(Group 36)

Group and Section Group 36 Section 001 name and UNI Name UNI Ningyu Jia nj2459 Mengyin Ma mm5937 code explanation Parking.py (1) Calculate the rate of

1 Dec 04, 2021
Python library to natively send files to Trash (or Recycle bin) on all platforms.

Send2Trash -- Send files to trash on all platforms Send2Trash is a small package that sends files to the Trash (or Recycle Bin) natively and on all pl

Andrew Senetar 224 Jan 04, 2023
More granular intermediaries for legacy Minecraft versions

Orinthe/Intermediary mappings This repository contains the match information between different versions of Minecraft created by the Orinthe project, a

4 Jan 11, 2022
Turn a raspberry pi into a Bluetooth Midi device

PiBluetoothMidSetup This will change serveral system wide packages/configurations Do not run this on your primary machine or anything you don't know h

MyLab6 40 Sep 19, 2022
Data on COVID-19 (coronavirus) cases, deaths, hospitalizations, tests • All countries • Updated daily by Our World in Data

COVID-19 Dataset by Our World in Data Find our data on COVID-19 and its documentation in public/data. Documentation Data: complete COVID-19 dataset Da

Our World in Data 5.5k Jan 03, 2023
Pattern Matching for Python 3.7+ in a simple, yet powerful, extensible manner.

Awesome Pattern Matching (apm) for Python pip install awesome-pattern-matching Simple Powerful Extensible Composable Functional Python 3.7+, PyPy3.7+

Julian Fleischer 97 Nov 03, 2022
Block fingerprinting for the beacon chain, for client identification & client diversity metrics

blockprint This is a repository for discussion and development of tools for Ethereum block fingerprinting. The primary aim is to measure beacon chain

Sigma Prime 49 Dec 08, 2022
An unofficial python API for trading on the DeGiro platform, with the ability to get real time data and historical data.

DegiroAPI An unofficial API for the trading platform Degiro written in Python with the ability to get real time data and historical data for products.

Jorrick Sleijster 5 Dec 16, 2022
奇遇淘客服务器端

奇遇淘客 APP 服务器端 警告 正在使用 v0.2.0 版本的用户,请尽快升级到 v0.2.1。 v0.2.0 版本的 Docker 镜像中包含了有问题的 aiohttp。 奇遇淘客代码库 奇遇淘客 iOS APP 奇遇淘客 Android APP 奇遇淘客文档 服务器端文档 Docker 使用

奇遇科技 92 Nov 09, 2022
Object-oriented programming (OOP) is a method of structuring a program by bundling related properties and behaviors into individual objects. In this tutorial, you’ll learn the basics of object-oriented programming in Python.

06_Python_Object_Class Introduction 👋 Objected oriented programming as a discipline has gained a universal following among developers. Python, an in-

Milaan Parmar / Милан пармар / _米兰 帕尔马 239 Dec 20, 2022
A Python library for inspecting JVM class files (.class)

lawu Lawu is a human-friendly library for assembling, disassembling, and exploring JVM class files. It's highly suitable for automation tasks. Documen

Tyler Kennedy 45 Oct 23, 2022
Gunakan Dengan Bijak!!

YMBF Made with ❤️ by ikiwzXD_ menu Results notice me: if you get cp results, save 3/7 days then log in. Install script on Termux $ pkg update && pkg u

Ikiwz 0 Jul 11, 2022
Python 100daysofcode

#python #100daysofcode Python is a simple, general purpose ,high level & object-oriented programming language even it's is interpreted scripting langu

Tara 1 Feb 10, 2022
This is a simple analogue clock made with turtle in python...

Analogue-Clock This is a simple analogue clock made with turtle in python... Requirements None, only you need to have windows 😉 ...Enjoy! Installatio

Abhyush 3 Jan 14, 2022
Lags valorant servers by rapidly picking up and throwing shorties.

Lags valorant servers by rapidly picking up and throwing shorties.

Eric Still 9 Dec 30, 2021
ColabFold / AlphaFold2_advanced on your local PC (or macOS)

LocalColabFold ColabFold / AlphaFold2_advanced on your local PC (or macOS) Installation For Linux Make sure curl and wget commands are already install

Yoshitaka Moriwaki 207 Dec 22, 2022
Werkzeug has a debug console that requires a pin. It's possible to bypass this with an LFI vulnerability or use it as a local privilege escalation vector.

Werkzeug Debug Console Pin Bypass Werkzeug has a debug console that requires a pin by default. It's possible to bypass this with an LFI vulnerability

Wyatt Dahlenburg 23 Dec 17, 2022
Wordle Solver

Wordle Solver Installation Install the following onto your computer: Python 3.10.x Download Page Run pip install -r requirements.txt Instructions To r

John Bucknam 1 Feb 15, 2022
Double Pendulum implementation in Python, now with added pendulums and trails :D

Double Pendulum Using Curses in Python. A nice relaxing double pendulum simulation using ASCII, able to simulate multiple pendulums at once, and provi

Nekurone 62 Dec 14, 2022