Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 13ef47e

Browse files
committed
feat: add main and readme
1 parent d86ebf0 commit 13ef47e

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
# notforced
1+
This guide helps you download `main.py` and configure it within Marzban.
2+
3+
## Steps
4+
5+
1. **Download `main.py`**
6+
Download `main.py` from the repository to your Marzban directory:
7+
8+
```bash
9+
sudo wget -P /opt/marzban/ https://github.com/erfjab/notforced/blob/master/main.py
10+
```
11+
12+
2. **Edit `docker-compose.yml`**
13+
Open your `docker-compose.yml` file in the editor:
14+
15+
```bash
16+
nano /opt/marzban/docker-compose.yml
17+
```
18+
19+
3. **Add Volume Configuration**
20+
In the `volumes` section, add the following lines to link `main.py`:
21+
22+
```yaml
23+
volumes:
24+
- /var/lib/marzban:/var/lib/marzban
25+
- /opt/marzban/main.py:/code/main.py
26+
```
27+
28+
4. **Restart Marzban**
29+
To apply changes, restart Marzban:
30+
31+
```bash
32+
marzban restart
33+
```
34+
35+
All done! Marzban is now configured with the `main.py` file.

main.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import uvicorn
2+
from app import app
3+
from config import (
4+
DEBUG,
5+
UVICORN_HOST,
6+
UVICORN_PORT,
7+
UVICORN_UDS,
8+
UVICORN_SSL_CERTFILE,
9+
UVICORN_SSL_KEYFILE
10+
)
11+
import logging
12+
13+
if __name__ == "__main__":
14+
# Do NOT change workers count for now
15+
# multi-workers support isn't implemented yet for APScheduler and XRay module
16+
try:
17+
uvicorn.run(
18+
"main:app",
19+
host=('0.0.0.0' if DEBUG else UVICORN_HOST),
20+
port=UVICORN_PORT,
21+
uds=(None if DEBUG else UVICORN_UDS),
22+
ssl_certfile=UVICORN_SSL_CERTFILE,
23+
ssl_keyfile=UVICORN_SSL_KEYFILE,
24+
workers=1,
25+
reload=DEBUG,
26+
log_level=logging.DEBUG if DEBUG else logging.INFO
27+
)
28+
except FileNotFoundError: # to prevent error on removing unix sock
29+
pass

0 commit comments

Comments
 (0)