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
Commits
dc258ef8
Commit
dc258ef8
authored
1 year ago
by
hanfi
Browse files
Options
Downloads
Plain Diff
Merge branch 'staging' into 'main'
added more docu See merge request
!9
parents
81b3780b
33b00b6b
No related branches found
No related tags found
1 merge request
!9
added more docu
Changes
1
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
+
59
−
3
View file @
dc258ef8
# Chaos Parcel Serivce: Backend
# 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
## Deployment
This assumes you run the code as user
*www-data*
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 same user.
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)
checkout the code (main branch for production)
cd into the directory
cd into the directory
...
@@ -48,8 +87,13 @@ create a runtime directory to allow the webserver to forward calls to
...
@@ -48,8 +87,13 @@ create a runtime directory to allow the webserver to forward calls to
mdkir /run/bgp
mdkir /run/bgp
chown www-data:www-data /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]
[Unit]
Description=Gunicorn instance to serve bgp backend fastapi app
Description=Gunicorn instance to serve bgp backend fastapi app
...
@@ -64,3 +108,15 @@ ExecStart=/srv/backend/venv/bin/gunicorn -k uvicorn.workers.UvicornWorker --bind
...
@@ -64,3 +108,15 @@ ExecStart=/srv/backend/venv/bin/gunicorn -k uvicorn.workers.UvicornWorker --bind
[Install]
[Install]
WantedBy=multi-user.target
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.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment