Skip to content

Commit 83ccc2b

Browse files
committed
Modified config and made gunicorn config executable
1 parent 74ac26d commit 83ccc2b

7 files changed

+24
-21
lines changed

config/gunicorn/analytics-dev.gunicorn.sh

100644100755
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
# Project directory
4-
PROJECTDIR=/webapps/demo-analytics-dev
4+
PROJECTDIR=/webapps/demo-analytics-dev/src
55
# App instance module
6-
ASGI_MODULE=src/server.asgi
6+
ASGI_MODULE=server.asgi
77
# we will communicte using this unix socket
88
SOCKFILE=/webapps/demo-analytics-dev/run/unicorn_dev.sock
99

@@ -15,7 +15,7 @@ GROUP=webapps
1515
# Number of Workers
1616
NUM_WORKERS=1
1717

18-
WORKER_CLASS=venv/lib/uvicorn.workers.UvicornWorker
18+
WORKER_CLASS=uvicorn.workers.UvicornWorker
1919

2020
TIMEOUT=300
2121
GRACEFUL_TIMEOUT=120
@@ -27,15 +27,15 @@ echo "Starting $NAME as `whoami`"
2727

2828
# Activate the virtual environment
2929
cd $PROJECTDIR
30-
source venv/bin/activate
30+
source ../venv/bin/activate
3131

3232
# Create the run directory if it doesn't exist
3333
RUNDIR=$(dirname $SOCKFILE)
3434
test -d $RUNDIR || mkdir -p $RUNDIR
3535

3636
# Start your Unicorn
3737
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
38-
exec venv/bin/gunicorn ${ASGI_MODULE}:app \
38+
exec ../venv/bin/gunicorn ${ASGI_MODULE}:app \
3939
--worker-class $WORKER_CLASS \
4040
--workers $NUM_WORKERS \
4141
--timeout $TIMEOUT \

config/gunicorn/analytics-pre-dev.gunicorn.sh

100644100755
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
# Project directory
4-
PROJECTDIR=/webapps/demo-analytics-pre-dev
4+
PROJECTDIR=/webapps/demo-analytics-pre-dev/src
55
# App instance module
6-
ASGI_MODULE=src/server.asgi
6+
ASGI_MODULE=server.asgi
77
# we will communicte using this unix socket
88
SOCKFILE=/webapps/demo-analytics-pre-dev/run/unicorn_pre_dev.sock
99

@@ -15,7 +15,7 @@ GROUP=webapps
1515
# Number of Workers
1616
NUM_WORKERS=1
1717

18-
WORKER_CLASS=venv/lib/uvicorn.workers.UvicornWorker
18+
WORKER_CLASS=uvicorn.workers.UvicornWorker
1919

2020
TIMEOUT=300
2121
GRACEFUL_TIMEOUT=120
@@ -27,15 +27,15 @@ echo "Starting $NAME as `whoami`"
2727

2828
# Activate the virtual environment
2929
cd $PROJECTDIR
30-
source venv/bin/activate
30+
source ../venv/bin/activate
3131

3232
# Create the run directory if it doesn't exist
3333
RUNDIR=$(dirname $SOCKFILE)
3434
test -d $RUNDIR || mkdir -p $RUNDIR
3535

3636
# Start your Unicorn
3737
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
38-
exec venv/bin/gunicorn ${ASGI_MODULE}:app \
38+
exec ../venv/bin/gunicorn ${ASGI_MODULE}:app \
3939
--worker-class $WORKER_CLASS \
4040
--workers $NUM_WORKERS \
4141
--timeout $TIMEOUT \

config/gunicorn/analytics.gunicorn.sh

100644100755
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
# Project directory
4-
PROJECTDIR=/webapps/demo-analytics
4+
PROJECTDIR=/webapps/demo-analytics/src
55
# App instance module
6-
ASGI_MODULE=src/server.asgi
6+
ASGI_MODULE=server.asgi
77
# we will communicte using this unix socket
88
SOCKFILE=/webapps/demo-analytics/run/unicorn_live.sock
99

@@ -15,7 +15,7 @@ GROUP=webapps
1515
# Number of Workers
1616
NUM_WORKERS=3
1717

18-
WORKER_CLASS=venv/lib/uvicorn.workers.UvicornWorker
18+
WORKER_CLASS=uvicorn.workers.UvicornWorker
1919

2020
TIMEOUT=300
2121
GRACEFUL_TIMEOUT=120
@@ -27,15 +27,15 @@ echo "Starting $NAME as `whoami`"
2727

2828
# Activate the virtual environment
2929
cd $PROJECTDIR
30-
source venv/bin/activate
30+
source ../venv/bin/activate
3131

3232
# Create the run directory if it doesn't exist
3333
RUNDIR=$(dirname $SOCKFILE)
3434
test -d $RUNDIR || mkdir -p $RUNDIR
3535

3636
# Start your Unicorn
3737
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
38-
exec venv/bin/gunicorn ${ASGI_MODULE}:app \
38+
exec ../venv/bin/gunicorn ${ASGI_MODULE}:app \
3939
--worker-class $WORKER_CLASS \
4040
--workers $NUM_WORKERS \
4141
--timeout $TIMEOUT \

config/supervisor/analytics-develop.supervisor.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:analytics_dev]
2-
command = /webapps/demo-analytics-dev/conf/gunicorn/analytics-dev.gunicorn.sh
2+
command = /webapps/demo-analytics-dev/config/gunicorn/analytics-dev.gunicorn.sh
33
user = demo-analytics-dev
44
# stdout_logfile = /webapps/freadom/dev/log/dev-supervisor.log
55
# redirect_stderr = true

config/supervisor/analytics-pre-dev.supervisor.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:analytics_pre_dev]
2-
command = /webapps/demo-analytics-pre-dev/conf/gunicorn/analytics-pre-dev.gunicorn.sh
2+
command = /webapps/demo-analytics-pre-dev/config/gunicorn/analytics-pre-dev.gunicorn.sh
33
user = demo-analytics-pre-dev
44
# stdout_logfile = /webapps/freadom/dev/log/dev-supervisor.log
55
# redirect_stderr = true

config/supervisor/analytics.supervisor.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:analytics_live]
2-
command = /webapps/demo-analytics/conf/gunicorn/analytics.gunicorn.sh
2+
command = /webapps/demo-analytics/config/gunicorn/analytics.gunicorn.sh
33
user = demo-analytics
44
# stdout_logfile = /webapps/freadom/dev/log/dev-supervisor.log
55
# redirect_stderr = true

src/core/settings.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import logging
22
import sys
3+
import os
34
from typing import List
45

56
from starlette.config import Config
67
from starlette.datastructures import CommaSeparatedStrings, Secret
78

9+
SRC_DIR = os.path.dirname(os.path.dirname(__file__))
10+
11+
config = Config(os.path.join(os.path.dirname(SRC_DIR), ".env"))
812

9-
config = Config(".env")
1013
DEBUG: bool = config("DEBUG", cast=bool, default=False)
1114
SECRET_KEY: Secret = config(
1215
"SECRET_KEY", default="UBzPj7Qj29K4z4aeCqZ40xi8dVdTbbch", cast=Secret
@@ -15,8 +18,8 @@
1518
VERSION: str = config("VERSION", default="1.0.0")
1619
MONGO_URI: str = config("MONGO_URI", default="mongodb://127.0.0.1:27017")
1720
MONGO_DB_NAME: str = config("MONGO_DB_NAME", default="demo_db")
18-
MONGO_MAX_POOL_SIZE: int = config("MONGO_MAX_POOL_SIZE", default=2)
19-
MONGO_MIN_POOL_SIZE: int = config("MONGO_MIN_POOL_SIZE", default=15)
21+
MONGO_MAX_POOL_SIZE: int = config("MONGO_MAX_POOL_SIZE", default=15)
22+
MONGO_MIN_POOL_SIZE: int = config("MONGO_MIN_POOL_SIZE", default=2)
2023
ALLOWED_HOSTS: List[str] = config(
2124
"ALLOWED_HOSTS", cast=CommaSeparatedStrings, default=""
2225
)

0 commit comments

Comments
 (0)