mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 21:54:13 +01:00
make log rotate days configurable
This commit is contained in:
parent
0383c3fb8b
commit
bc3d859571
@ -3,7 +3,14 @@ set -e
|
||||
echo "Log rotate starting..."
|
||||
|
||||
#The logs n days before will be compressed.
|
||||
n=14
|
||||
n=$LOG_ROTATE_DAYS
|
||||
if [ -z "$n" ]
|
||||
then
|
||||
n=3
|
||||
fi
|
||||
|
||||
echo "logs rotate days: $n"
|
||||
|
||||
path=/var/log/docker
|
||||
|
||||
list=""
|
||||
|
1
make/common/templates/log/env
Normal file
1
make/common/templates/log/env
Normal file
@ -0,0 +1 @@
|
||||
LOG_ROTATE_DAYS=$log_rotate_days
|
@ -5,6 +5,8 @@ services:
|
||||
context: ../../
|
||||
dockerfile: make/photon/log/Dockerfile
|
||||
container_name: harbor-log
|
||||
env_file:
|
||||
- ../common/config/log/env
|
||||
restart: always
|
||||
volumes:
|
||||
- /var/log/harbor/:/var/log/docker/:z
|
||||
|
@ -3,6 +3,8 @@ services:
|
||||
log:
|
||||
image: vmware/harbor-log:__version__
|
||||
container_name: harbor-log
|
||||
env_file:
|
||||
- ./common/config/log/env
|
||||
restart: always
|
||||
volumes:
|
||||
- /var/log/harbor/:/var/log/docker/:z
|
||||
|
@ -34,6 +34,9 @@ admiral_url = NA
|
||||
#Please update it before deployment, subsequent update will cause Clair's API server and Harbor unable to access Clair's database.
|
||||
clair_db_password = password
|
||||
|
||||
#The logs n days before will be compressed
|
||||
log_rotate_days = 3
|
||||
|
||||
#NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES
|
||||
#only take effect in the first boot, the subsequent changes of these properties
|
||||
#should be performed on web ui
|
||||
|
@ -4,7 +4,7 @@ ADD make/common/log/rsyslog.conf /etc/rsyslog.conf
|
||||
|
||||
# rotate logs weekly
|
||||
# notes: file name cannot contain dot, or the script will not run
|
||||
ADD make/common/log/rotate.sh /etc/cron.weekly/rotate
|
||||
ADD make/common/log/rotate.sh /etc/cron.daily/rotate
|
||||
|
||||
# rsyslog configuration file for docker
|
||||
ADD make/common/log/rsyslog_docker.conf /etc/rsyslog.d/
|
||||
|
@ -161,6 +161,7 @@ uaa_endpoint = rcp.get("configuration", "uaa_endpoint")
|
||||
uaa_clientid = rcp.get("configuration", "uaa_clientid")
|
||||
uaa_clientsecret = rcp.get("configuration", "uaa_clientsecret")
|
||||
secret_key = get_secret_key(secretkey_path)
|
||||
log_rotate_days = rcp.get("configuration", "log_rotate_days")
|
||||
########
|
||||
|
||||
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
||||
@ -176,6 +177,7 @@ job_config_dir = prep_conf_dir(config_dir, "jobservice")
|
||||
registry_config_dir = prep_conf_dir(config_dir, "registry")
|
||||
nginx_config_dir = prep_conf_dir (config_dir, "nginx")
|
||||
nginx_conf_d = prep_conf_dir(nginx_config_dir, "conf.d")
|
||||
log_config_dir = prep_conf_dir (config_dir, "log")
|
||||
|
||||
adminserver_conf_env = os.path.join(config_dir, "adminserver", "env")
|
||||
ui_conf_env = os.path.join(config_dir, "ui", "env")
|
||||
@ -185,7 +187,8 @@ registry_conf = os.path.join(config_dir, "registry", "config.yml")
|
||||
db_conf_env = os.path.join(config_dir, "db", "env")
|
||||
job_conf_env = os.path.join(config_dir, "jobservice", "env")
|
||||
nginx_conf = os.path.join(config_dir, "nginx", "nginx.conf")
|
||||
cert_dir = os.path.join(config_dir, "nginx", "cert")
|
||||
cert_dir = os.path.join(config_dir, "nginx", "cert")
|
||||
log_conf_env = os.path.join(config_dir, "log", "env")
|
||||
|
||||
if protocol == "https":
|
||||
target_cert_path = os.path.join(cert_dir, os.path.basename(cert_path))
|
||||
@ -261,6 +264,10 @@ render(os.path.join(templates_dir, "jobservice", "env"),
|
||||
job_conf_env,
|
||||
ui_secret=ui_secret,
|
||||
jobservice_secret=jobservice_secret)
|
||||
|
||||
render(os.path.join(templates_dir, "log", "env"),
|
||||
log_conf_env,
|
||||
log_rotate_days=log_rotate_days)
|
||||
|
||||
print("Generated configuration file: %s" % jobservice_conf)
|
||||
shutil.copyfile(os.path.join(templates_dir, "jobservice", "app.conf"), jobservice_conf)
|
||||
|
Loading…
Reference in New Issue
Block a user