Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
b7b62183
Unverified
Commit
b7b62183
authored
Feb 19, 2019
by
老广
Committed by
GitHub
Feb 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2414 from jumpserver/dev
[Update] gunicorn的日志
parents
4d402617
5a1b8941
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
10 deletions
+25
-10
utils.py
apps/common/utils.py
+2
-2
settings.py
apps/jumpserver/settings.py
+18
-2
signal_handler.py
apps/ops/celery/signal_handler.py
+5
-5
jms
jms
+0
-1
No files found.
apps/common/utils.py
View file @
b7b62183
...
...
@@ -69,13 +69,13 @@ class Signer(metaclass=Singleton):
self
.
secret_key
=
secret_key
def
sign
(
self
,
value
):
s
=
JSONWebSignatureSerializer
(
self
.
secret_key
)
s
=
JSONWebSignatureSerializer
(
self
.
secret_key
,
algorithm_name
=
'HS256'
)
return
s
.
dumps
(
value
)
.
decode
()
def
unsign
(
self
,
value
):
if
value
is
None
:
return
value
s
=
JSONWebSignatureSerializer
(
self
.
secret_key
)
s
=
JSONWebSignatureSerializer
(
self
.
secret_key
,
algorithm_name
=
'HS256'
)
try
:
return
s
.
loads
(
value
)
except
BadSignature
:
...
...
apps/jumpserver/settings.py
View file @
b7b62183
...
...
@@ -26,6 +26,7 @@ CONFIG = load_user_config()
LOG_DIR
=
os
.
path
.
join
(
PROJECT_DIR
,
'logs'
)
JUMPSERVER_LOG_FILE
=
os
.
path
.
join
(
LOG_DIR
,
'jumpserver.log'
)
ANSIBLE_LOG_FILE
=
os
.
path
.
join
(
LOG_DIR
,
'ansible.log'
)
GUNICORN_LOG_FILE
=
os
.
path
.
join
(
LOG_DIR
,
'gunicorn.log'
)
if
not
os
.
path
.
isdir
(
LOG_DIR
):
os
.
makedirs
(
LOG_DIR
)
...
...
@@ -213,10 +214,21 @@ LOGGING = {
'ansible_logs'
:
{
'encoding'
:
'utf8'
,
'level'
:
'DEBUG'
,
'class'
:
'logging.FileHandler'
,
'class'
:
'logging.
handlers.Rotating
FileHandler'
,
'formatter'
:
'main'
,
'maxBytes'
:
1024
*
1024
*
100
,
'backupCount'
:
7
,
'filename'
:
ANSIBLE_LOG_FILE
,
},
'gunicorn_logs'
:
{
'encoding'
:
'utf8'
,
'level'
:
'DEBUG'
,
'class'
:
'logging.handlers.RotatingFileHandler'
,
'formatter'
:
'main'
,
'maxBytes'
:
1024
*
1024
*
100
,
'backupCount'
:
2
,
'filename'
:
GUNICORN_LOG_FILE
,
},
},
'loggers'
:
{
'django'
:
{
...
...
@@ -254,6 +266,10 @@ LOGGING = {
'handlers'
:
[
'console'
,
'file'
],
'level'
:
"INFO"
,
},
'gunicorn'
:
{
'handlers'
:
[
'console'
,
'gunicorn_logs'
],
'level'
:
LOG_LEVEL
,
},
# 'django.db': {
# 'handlers': ['console', 'file'],
# 'level': 'DEBUG'
...
...
@@ -428,7 +444,7 @@ CELERY_WORKER_LOG_FORMAT = '%(message)s'
CELERY_TASK_EAGER_PROPAGATES
=
True
CELERY_WORKER_REDIRECT_STDOUTS
=
True
CELERY_WORKER_REDIRECT_STDOUTS_LEVEL
=
"INFO"
# CELERY_WORKER_HIJACK_ROOT_LOGGER =
Fals
e
# CELERY_WORKER_HIJACK_ROOT_LOGGER =
Tru
e
CELERY_WORKER_MAX_TASKS_PER_CHILD
=
40
# Cache use redis
...
...
apps/ops/celery/signal_handler.py
View file @
b7b62183
...
...
@@ -5,7 +5,7 @@ import logging
from
django.core.cache
import
cache
from
celery
import
subtask
from
celery.signals
import
(
worker_ready
,
worker_shutdown
,
after_setup_logger
worker_ready
,
worker_shutdown
,
after_setup_logger
,
setup_logging
)
from
kombu.utils.encoding
import
safe_str
from
django_celery_beat.models
import
PeriodicTask
...
...
@@ -45,8 +45,8 @@ def after_app_shutdown_periodic_tasks(sender=None, **kwargs):
def
add_celery_logger_handler
(
sender
=
None
,
logger
=
None
,
loglevel
=
None
,
format
=
None
,
**
kwargs
):
if
not
logger
:
return
handler
=
CeleryTaskFileHandler
()
handler
.
setLevel
(
loglevel
)
task_
handler
=
CeleryTaskFileHandler
()
task_
handler
.
setLevel
(
loglevel
)
formatter
=
logging
.
Formatter
(
format
)
handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
handler
)
task_
handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
task_
handler
)
jms
View file @
b7b62183
...
...
@@ -149,7 +149,6 @@ def start_gunicorn():
if
DAEMON
:
cmd
.
extend
([
'--access-logfile'
,
log_file
,
'--daemon'
,
])
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment