Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Add/Dependencies and docs for deployment and installation (#8)
Browse files Browse the repository at this point in the history
* Add docs, project resources and install deps script

* Remove submodule

* rm deps

* Add deps

* Edit readme

* Remove mistake from main.go
  • Loading branch information
tordnat authored Mar 12, 2024
1 parent 9dbbb61 commit 4b11a85
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Simulator-v2/
Secret-Homework1/
.DS_Store
.vscode
hall_request_assigner

# Binaries for programs and plugins
*.exe
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "hallRequestAssigner"]
path = Project-resources
url = https://github.com/TTK4145/Project-resources.git
1 change: 1 addition & 0 deletions Project-resources
Submodule Project-resources added at a1cdf0
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,61 @@
# elevator-project
# Elevator project - TTK4145

[![Go](https://github.com/tordnat/elevator-project/actions/workflows/build_go.yml/badge.svg)](https://github.com/tordnat/elevator-project/actions/workflows/build_go.yml)
Elevator project for Real-time Programming TTK4145 at NTNU. This a distributed program which is designed to handle multiple elevators on a network concurrently in a fail-safe manner.

Elevator project for Real-time Programming TTK4145 at NTNU
## Cloning the repository
Since we have git submodules you need to clone the repository recursively:
`git clone --recursive link.to.repo.git `

## To-do:
- Logging functionality 🤓
- Printing MORE elevators simul. 🛗🛗🛗🛗
## Dependencies

This project requires the following dependencies to be installed on the host machine:
- `elevatorserver` or `elevatorsimulator` needs to be installed and on the path of the root user
- `golang` >= 1.21 For the distributed elevator program
- `dmd` D-lang compiler for the hall request assigner

Snippets:
`sudo apt install golang`
`sudo apt install dmd`

You can also use the installation script in the `scripts/` folder in the root directory of this repository:
`chmod +x scripts/install_deps.sh`

> Note: If DMD is not in apt sources, visit https://dlang.org/download.html for dmd download
## Deployment

To deploy an instance of an elevator you only need to run:
`sudo ./scripts/create_and_start_elevatorservice.sh 1`
Where the argument specifies the ID of that instance. The script does the following:
- Make a config directory `~/.config/elevator/`
- build the elevator program and copy to `~/.config/elevator/`
- Copy the template systemd service file `[email protected]` to `/etc/systemd/system`
- Start the `elevatorserver`
- Enable and start the service with given ID

You can use systemctl to stop, start or view the status of a running elevator:

`sudo systemctl start elevator@1`

`sudo systemctl stop elevator@1`

`sudo systemctl status elevator@1`

## Un-deployment: Removing the elevator
To remove the elvatorservice and it's configuration files you can use the following command:

`sudo ./scripts/stop_and_remove_elevatorservice.sh 1`

"1" being the instance you want to remove.

## Manual deployment

To deploy the elevator manually you can run the elevatorserver:

`elevatorserver --port myport`

and then run the elevator program:

`go run main.go --id myid --port myport`

> This is not part of the deployment, but is useful for testing (we use systemd for resetting our system from fail states)
Binary file removed hall_request_assigner
Binary file not shown.
11 changes: 11 additions & 0 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

echo "Installing dependencies"
sudo apt install golang
sudo apt install dmd

HRA_INSTALL_PATH="elevatorAlgorithm/hra/"
echo "Building project and moving hall_request_assigner to workspace root"
chmod +x Project-resources/cost_fns/hall_request_assigner/build.sh
Project-resources/cost_fns/hall_request_assigner/build.sh
sudo cp Project-resources/cost_fns/hall_request_assigner $HRA_INSTALL_PATH

0 comments on commit 4b11a85

Please sign in to comment.