File tree 4 files changed +126
-18
lines changed
4 files changed +126
-18
lines changed Original file line number Diff line number Diff line change
1
+ FROM python:3.6
2
+ # ENV PYTHONDONTWRITEBYTECODE 1
3
+ ENV PYTHONUNBUFFERED 1
4
+
5
+ RUN mkdir -p /home/app
6
+
7
+ ENV HOME=/home/app
8
+ ENV APP_HOME=/home/app/web
9
+ RUN mkdir $APP_HOME
10
+ WORKDIR $APP_HOME
11
+
12
+ ADD /requirements/local.txt $APP_HOME
13
+
14
+ RUN export https_proxy=http://10.46.0.210:3128; \
15
+ export http_proxy=http://10.46.0.210:3128; \
16
+ pip install gunicorn; \
17
+ pip install -r /home/app/web/local.txt; mkdir /log;
Original file line number Diff line number Diff line change 3
3
from celery .schedules import crontab
4
4
5
5
class Config :
6
- pass
6
+ JSONIFY_PRETTYPRINT_REGULAR = True
7
7
8
8
class Celery :
9
9
BROKER_URL = os .getenv ('CELERY_BROKER_URL' ,'redis://redis:6379/0' )
Original file line number Diff line number Diff line change 1
1
import os
2
2
import logging
3
+ from logging .handlers import RotatingFileHandler
3
4
4
5
BASE_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
6
+ LOG_FILENAME_INFO = BASE_DIR + '/logs/info.log'
5
7
6
- class LoggingConf :
7
- LOG_FILENAME_INFO = BASE_DIR + '/logs/info.log'
8
- LOG_FILENAME_ERROR = BASE_DIR + '/logs/error.log'
9
- LOG_FILENAME_CRITICAL = BASE_DIR + '/logs/critical.log'
10
- FORMAT = '%(asctime)s,%(msecs)05.1f %(message)s'
11
- DATEFMT = '%m/%d/%Y %H:%M:%S'
8
+ logging .basicConfig (
9
+ handlers = [
10
+ logging .StreamHandler (),
11
+ RotatingFileHandler (LOG_FILENAME_INFO , maxBytes = 20000 , backupCount = 10 )
12
+ ],
13
+ level = logging .INFO ,
14
+ format = '[%(asctime)s] [%(pathname)s:%(lineno)d] [%(levelname)s] - %(message)s' ,
15
+ datefmt = '%d/%m/%Y %H:%M:%S'
16
+ )
17
+
18
+ logger = logging .getLogger ("launchpad" )
19
+
20
+ def gene_extra (ms ):
21
+ return {
22
+ 'id' :str (uuid .uuid4 ()),
23
+ 'msisdn' : ms
24
+ }
12
25
13
- logger = logging .getLogger ()
14
- logger .setLevel (logging .INFO )
15
- fh = logging .FileHandler (LoggingConf .LOG_FILENAME_INFO )
16
- fh .setLevel (logging .INFO )
17
- ch = logging .StreamHandler ()
18
- ch .setLevel (logging .DEBUG )
19
- formatter = logging .Formatter (LoggingConf .FORMAT )
20
- ch .setFormatter (formatter )
21
- fh .setFormatter (formatter )
22
- logger .addHandler (ch )
23
- logger .addHandler (fh )
24
26
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+
3
+ services :
4
+ web :
5
+ container_name : nginx
6
+ env_file : .env
7
+ environment :
8
+ - EX_PORT_NGINX=$EX_PORT_NGINX
9
+ - PORT_NGINX=$PORT_NGINX
10
+ image : nginx:alpine
11
+ restart : always
12
+
13
+ ports :
14
+ - " $EX_PORT_NGINX:$PORT_NGINX"
15
+ volumes :
16
+ - ./logs:/log
17
+ - ./nginx/site.conf:/etc/nginx/conf.d/default.conf
18
+ - /etc/localtime:/etc/localtime:ro
19
+ links :
20
+ - app
21
+ logging :
22
+ driver : " json-file"
23
+ options :
24
+ max-size : " 5m"
25
+ max-file : " 10"
26
+ app :
27
+ container_name : flask-app
28
+ env_file : .env
29
+ build :
30
+ context : .
31
+ dockerfile : ./compose/stage/Dockerfile
32
+ restart : always
33
+ command : gunicorn wsgi:app -b 0.0.0.0:8011 --log-level=info
34
+ volumes :
35
+ - ./src:/home/app/web/
36
+ - ./logs:/home/app/web/logs
37
+ - /etc/localtime:/etc/localtime:ro
38
+ links :
39
+ - redis
40
+ logging :
41
+ driver : " json-file"
42
+ options :
43
+ max-size : " 5m"
44
+ max-file : " 10"
45
+ worker :
46
+ container_name : worker1
47
+ env_file : .env
48
+ build :
49
+ context : .
50
+ dockerfile : ./compose/stage/Dockerfile
51
+ restart : always
52
+ command : celery -A app.task worker --loglevel=info -f logs/beat.log
53
+ volumes :
54
+ - ./src:/home/app/web/
55
+ - ./logs:/home/app/web/logs
56
+ - /etc/localtime:/etc/localtime:ro
57
+ links :
58
+ - redis
59
+ logging :
60
+ driver : " json-file"
61
+ options :
62
+ max-size : " 5m"
63
+ max-file : " 10"
64
+ beat :
65
+ container_name : beat1
66
+ env_file : .env
67
+ build :
68
+ context : .
69
+ dockerfile : ./compose/stage/Dockerfile
70
+ restart : always
71
+ command : celery -A app.task beat --loglevel=info
72
+ volumes :
73
+ - ./src:/home/app/web/
74
+ - ./logs:/home/app/web/logs
75
+ - /etc/localtime:/etc/localtime:ro
76
+ links :
77
+ - redis
78
+ logging :
79
+ driver : " json-file"
80
+ options :
81
+ max-size : " 5m"
82
+ max-file : " 10"
83
+ redis :
84
+ container_name : redis_ox
85
+ image : redis
86
+ volumes :
87
+ - ./data/redis:/data
88
+ - /etc/localtime:/etc/localtime:ro
89
+ restart : always
You can’t perform that action at this time.
0 commit comments