Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaos Parcel Service
backend
Compare revisions
81b3780b7262d472cc3deb86ae59064bdaed9e3e to dc258ef827baa0c1d3b4e944e469da26f7fe990b
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
chaos-parcel-service/bgp_backend
Select target project
No results found
dc258ef827baa0c1d3b4e944e469da26f7fe990b
Select Git revision
Branches
main
staging
Swap
Target
chaos-parcel-service/bgp_backend
Select target project
chaos-parcel-service/bgp_backend
1 result
81b3780b7262d472cc3deb86ae59064bdaed9e3e
Select Git revision
Branches
main
staging
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
added more docu
· 33b00b6b
hanfi
authored
1 year ago
Verified
33b00b6b
Merge branch 'staging' into 'main'
· dc258ef8
hanfi
authored
1 year ago
added more docu See merge request
!9
dc258ef8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+59
-3
59 additions, 3 deletions
README.md
with
59 additions
and
3 deletions
README.md
View file @
dc258ef8
# Chaos Parcel Serivce: Backend
The backend is a simple FastAPI app (https://fastapi.tiangolo.com/) usign a sqlite database
## Development
To test and develop, you can run it on your computer.
check the repo out and change your workign directory into the top level
create a virtual env
```
python -m venv venv
```
activate the virtual env
```
. venv/bin/activate
```
install required dependencies
```
pip install -r requirements.txt
pip install -r requirements-dev.txt
```
for development, use the uvicorn server
```
pip install uvicorn
```
now you can run the app
```
uvicorn backend.main:app --reload
```
It will use the default setting from backend/config.py
you can override settings using a .env file in the working directory
## Deployment
This assumes you run the code as user
*www-data*
Do
**not**
checkout this code as the same user.
This assumes you run the code as user
*www-data*
and the code is checked out at /srv/backend
Do
**not**
checkout this code as the user ruining the code. the
**onyl**
requried writeable location is the database directory/file
checkout the code (main branch for production)
cd into the directory
...
...
@@ -48,8 +87,13 @@ create a runtime directory to allow the webserver to forward calls to
mdkir /run/bgp
chown www-data:www-data /run/bgp
```
on production systems you may want to create a /etc/tmpfiles.d/bgp_backend.conf
```
d /run/bgp/ 0750 www-data www-data - -
```
to create the file on boot
create a systemd service file to serve the app:
create a systemd service file to serve the app
in /etc/systemd/system/bgp_backend.service
:
```
[Unit]
Description=Gunicorn instance to serve bgp backend fastapi app
...
...
@@ -64,3 +108,15 @@ ExecStart=/srv/backend/venv/bin/gunicorn -k uvicorn.workers.UvicornWorker --bind
[Install]
WantedBy=multi-user.target
```
now you can run the app
```
systemctl daemon-reload
systemctl start bgp_backend
```
in your webserver use the socket at /run/bgp/socket to connect the webserver to the app
on nginx the backend url would look like this:
```
unix:/run/bgp/socket
```
This diff is collapsed.
Click to expand it.