Simulation of the IPPTS algorithm (task scheduling algorithm) using a distributed system of servers. This repository has the code for the master and slave servers.
Repository for the frontend: https://github.com/Malika01/ippts-simul-frontend
A simplified view (with important files and directories) is:
project root
--- master (subproject)
|--- src
|--- test
|--- package.json
|--- tsconfig.json
--- slave (subproject)
|--- src
|--- test
|--- package.json
|--- tsconfig.json
--- common
|--- src
|--- types
|--- tsconfig.json
--- proto
--- scripts
--- package.json
--- tsconfig.json
The master
and slave
directories are typescript subprojects for the master server and the slave servers respectively.
The common
folder has common type definitions for slave and master. The proto
folder has the ProtoBuf definitions for gRPC; these files will be used by both the master and the slaves.
The scripts
directory contains useful OS-specific scripts for generating typescript definitions from the .proto files in the proto directory. These scripts need not be invoked directly (running npm run build
from the project root directory runs them automatically).
The master
and slave
subprojects have their own package.json
and their own dependencies. This project as a whole also has some dependencies common to both of them (mostly typescript type definitions) that can be found in the package.json file of the root folder of the repository.
This separation into subprojects allows working on them in an easier way, and also allows separate dependency management.
First of all, you would want to run npm install
in the project root folder, in the master
folder and in the slave
folder. So run from the project root directory:
npm install
cd master
npm install
cd ../slave
npm install
Then, to build master
and slave
subprojects both, run this from the project root directory:
npm run build
To build a single subproject (like the master
subproject), do this from the project root directory:
For master subproject (from project root directory):
cd master
npm run build
For slave subproject (from project root directory):
cd slave
npm run build
Note:
- If there are any changes in the proto folder (like new .proto files or modifications to existing ones), then please run
npm run proto-gen
from the project root directory to generate updated typescript definitions from the .proto files. - If you run
npm run build
from the project root directory, thennpm run proto-gen
is executed automatically before building themaster
andslave
projects. However, it will not be executed ifnpm run build
is run from within themaster
or theslave
folder. - Currently,
npm run proto-gen
only works on Windows systems. An equivalent shell script for POSIX based systems will be added soon.
The master
and slave
subprojects have their own tests for now (integration tests may be added later) that use mocha and chai.
To run all tests in master
and slave
, run the following from the project root directory:
npm run test
To run tests for a subproject, cd
into that folder and then run npm test
(after installing dependencies).
So, from the project root directory, for running the slave server tests, run:
cd slave
npm run test
And for running the master server tests, from the project root directory, run:
cd master
npm run test
This section describes how you can create a docker image, run a container using that image, and push the image to docker hub.
Currently, these scripts are set up only for the slave server subproject (since its development is complete), but will also be set up for the master server subproject very soon.
Note: Ensure that docker is set up on your system and you are logged in with your Docker Hub account if you want to push to and pull images from Docker Hub.
The steps below describe the steps using the docker CLI. You can, of course, use a GUI for the same too (like Docker Desktop).
- From the project root directory, go to the slave subproject directory using:
cd slave
-
Now run the following based on what you want to do:
- To build a docker image, run:
npm run docker:build
- To run a container using the built image, run:
npm run docker:run
The docker container binds to 0.0.0.0:50051 by default if you use this command.
- To push a built image of the slave server to docker hub, run:
npm run docker:push
Alternatively, instead of building the docker image manually, you can pull the docker image from Docker Hub. (This may or may not be a little outdated though.)
See the Docker Hub repository for the backend and run the pull command there to pull the image. Use the tag slave
for pulling a docker image of the slave server.
So, run this to pull the docker image of the slave server:
docker pull sachett/ippts_simul_backend:slave
When the master
tag is added for the master server, you can pull the master server image using:
docker pull sachett/ippts_simul_backend:master