File tree Expand file tree Collapse file tree 5 files changed +23
-23
lines changed
pythonkr_backend/pythonkr_backend Expand file tree Collapse file tree 5 files changed +23
-23
lines changed Original file line number Diff line number Diff line change 1
1
# This will make sure the app is always imported when
2
2
# Django starts so that shared_task will use this app.
3
- from . celery import app as celery_app
3
+ from django . conf import settings
4
4
5
- __all__ = ('celery_app' ,)
5
+ if settings .CELERY_ALWAYS_EAGER is False :
6
+ from .celery import app as celery_app
7
+ __all__ = ('celery_app' ,)
8
+ else :
9
+ __all__ = ()
Original file line number Diff line number Diff line change 17
17
18
18
@worker_init .connect ()
19
19
def init_worker (* args , ** kwargs ):
20
- logfire .configure (service_name = "celery-worker" )
20
+ logfire .configure (service_name = "celery-worker" , send_to_logfire = 'if-token-present' )
21
21
logfire .instrument_celery ()
22
22
23
23
@beat_init .connect ()
24
24
def init_beat (* args , ** kwargs ):
25
- logfire .configure (service_name = "celery-beat" )
25
+ logfire .configure (service_name = "celery-beat" , send_to_logfire = 'if-token-present' )
26
26
logfire .instrument_celery ()
27
27
28
28
@app .task
Original file line number Diff line number Diff line change 187
187
"0.0.0.0" ,
188
188
]
189
189
190
- # LOGGING
191
-
192
- LOGGING = {
193
- "version" : 1 ,
194
- "disable_existing_loggers" : False ,
195
- "handlers" : {
196
- "console" : {
197
- "class" : "logging.StreamHandler" ,
198
- },
199
- },
200
- "root" : {
201
- "handlers" : ["console" ],
202
- "level" : "INFO" ,
203
- },
204
- }
205
-
206
190
# import logfire
207
191
# setup logfire
208
192
#logfire.configure(environment='base', service_name="web")
209
- #logfire.instrument_django()
193
+ #logfire.instrument_django()
194
+
195
+ # testing
196
+ CELERY_ALWAYS_EAGER = True
Original file line number Diff line number Diff line change 29
29
BAKERY_MULTISITE = True
30
30
BUILD_DIR = os .path .join ("/app/bakery_static" , "build" )
31
31
32
+
33
+ # check WSGI environment
34
+ IS_PRODUCTION_SERVER = os .environ .get ('IS_WSGI_ENVIRONMENT' , 'False' ) == 'True'
35
+
36
+
32
37
# logfire settings
33
38
if IS_PRODUCTION_SERVER :
34
39
logfire .configure (environment = 'localtest' )
35
- logfire .instrument_django ()
40
+ logfire .instrument_django ()
41
+
42
+ # testing
43
+ CELERY_ALWAYS_EAGER = True
Original file line number Diff line number Diff line change 73
73
CELERY_BROKER_USERNAME = os .environ .get ("CELERY_USERNAME" ,"FALSE" )
74
74
CELERY_BROKER_VHOST = os .environ .get ("CELERY_VHOST" ,"FALSE" )
75
75
# Celery Configuration Options
76
+ CELERY_ALWAYS_EAGER = False
76
77
CELERY_TIMEZONE = "Asia/Seoul"
77
78
CELERY_TASK_TRACK_STARTED = True
78
- CELERY_BROKER_URL = "amqp://userid:password @localhost:port/virtual_host "
79
+ CELERY_BROKER_URL = f "amqp://{ CELERY_BROKER_USERNAME } : { CELERY_BROKER_PASSWORD } @localhost:5672/ { CELERY_BROKER_VHOST } "
79
80
CELERY_TASK_TIME_LIMIT = 30 * 60
You can’t perform that action at this time.
0 commit comments