diff --git a/README.rst b/README.rst index 86e793a..9e46ee3 100644 --- a/README.rst +++ b/README.rst @@ -86,9 +86,9 @@ Deployment with Sqlite .. code:: bash - rm -rf /tmp/skyline && mkdir /tmp/skyline + rm -rf /tmp/skyline && mkdir /tmp/skyline && mkdir /var/log/skyline - docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest + docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /var/log/skyline:/var/log/skyline -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest # Check bootstrap is normal `exit 0` docker logs skyline_bootstrap @@ -105,7 +105,7 @@ Deployment with Sqlite .. code:: bash - docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest + docker run -d --name skyline --restart=always -v /var/log/skyline:/var/log/skyline -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest Deployment with MariaDB ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 4aa25ce..dd93a34 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -124,7 +124,7 @@ function configure_skyline { # devstack will not create internal interface # we can see more details from devstack/lib/keystone _skyline_config_set $SKYLINE_CONF_FILE "interface_type: *.*" "interface_type: public" - _skyline_config_set $SKYLINE_CONF_FILE "log_dir: *.*" "log_dir: /var/log" + _skyline_config_set $SKYLINE_CONF_FILE "log_dir: *.*" "log_dir: $SKYLINE_LOG_DIR" } # create_skyline_accounts() - Create required service accounts diff --git a/devstack/settings b/devstack/settings index c8005e0..c6e7c74 100644 --- a/devstack/settings +++ b/devstack/settings @@ -19,6 +19,4 @@ GITDIR["skyline-console"]=$DEST/skyline-console SKYLINE_CONF_DIR=${SKYLINE_CONF_DIR:-/etc/skyline} SKYLINE_CONF_FILE=${SKYLINE_CONF_DIR}/skyline.yaml SKYLINE_LOG_DIR=/var/log/skyline -SKYLINE_ERROR_LOG_FILE=${SKYLINE_LOG_DIR}/error.log -SKYLINE_ACCESS_LOG_FILE=${SKYLINE_LOG_DIR}/access.log SKYLINE_RUN_DIR=/var/lib/skyline diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index 49268ef..5bdaf99 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -16,6 +16,7 @@ file ``skyline.yaml.sample`` in ``etc`` directory. database_url: sqlite:////tmp/skyline.db debug: false log_dir: ./log + log_file: skyline.log prometheus_basic_auth_password: '' prometheus_basic_auth_user: '' prometheus_enable_basic_auth: false diff --git a/doc/source/install/docker-install-ubuntu.rst b/doc/source/install/docker-install-ubuntu.rst index 1a0ae11..8da63a3 100644 --- a/doc/source/install/docker-install-ubuntu.rst +++ b/doc/source/install/docker-install-ubuntu.rst @@ -115,7 +115,7 @@ We will install the Skyline APIServer service from docker image. default: database_url: mysql://skyline:SKYLINE_DBPASS@DB_SERVER:3306/skyline debug: true - log_dir: /var/log + log_dir: /var/log/skyline openstack: keystone_url: http://KEYSTONE_SERVER:5000/v3/ system_user_password: SKYLINE_SERVICE_PASSWORD diff --git a/doc/source/install/source-install-ubuntu.rst b/doc/source/install/source-install-ubuntu.rst index daf0fbb..bcc5d48 100644 --- a/doc/source/install/source-install-ubuntu.rst +++ b/doc/source/install/source-install-ubuntu.rst @@ -137,7 +137,7 @@ We will install the Skyline APIServer service from source code. default: database_url: mysql://skyline:SKYLINE_DBPASS@DB_SERVER:3306/skyline debug: true - log_dir: /var/log + log_dir: /var/log/skyline openstack: keystone_url: http://KEYSTONE_SERVER:5000/v3/ system_user_password: SKYLINE_SERVICE_PASSWORD diff --git a/etc/gunicorn.py b/etc/gunicorn.py index 82748b7..d62ffc3 100644 --- a/etc/gunicorn.py +++ b/etc/gunicorn.py @@ -44,12 +44,12 @@ logconfig_dict = { "error_file": { "class": "logging.handlers.RotatingFileHandler", "formatter": "generic", - "filename": "/var/log/skyline/error.log", + "filename": "/var/log/skyline/skyline-error.log", }, "access_file": { "class": "logging.handlers.RotatingFileHandler", "formatter": "generic", - "filename": "/var/log/skyline/access.log", + "filename": "/var/log/skyline/skyline-access.log", }, "console": { "class": "logging.StreamHandler", diff --git a/etc/skyline.yaml.sample b/etc/skyline.yaml.sample index a4bac97..c6f7961 100644 --- a/etc/skyline.yaml.sample +++ b/etc/skyline.yaml.sample @@ -5,6 +5,7 @@ default: database_url: sqlite:////tmp/skyline.db debug: false log_dir: ./log + log_file: skyline.log prometheus_basic_auth_password: '' prometheus_basic_auth_user: '' prometheus_enable_basic_auth: false diff --git a/releasenotes/notes/add-log-file-config-884e7d078feb43a7.yaml b/releasenotes/notes/add-log-file-config-884e7d078feb43a7.yaml new file mode 100644 index 0000000..fa61b01 --- /dev/null +++ b/releasenotes/notes/add-log-file-config-884e7d078feb43a7.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add ``log_file`` config into skyline.yaml.sample. Now the log + path of skyline is log_dir with log_file, no other hardcode path. diff --git a/skyline_apiserver/config/default.py b/skyline_apiserver/config/default.py index 82437e9..460e334 100644 --- a/skyline_apiserver/config/default.py +++ b/skyline_apiserver/config/default.py @@ -34,6 +34,13 @@ log_dir = Opt( default="./log", ) +log_file = Opt( + name="log_file", + description="Log file", + schema=StrictStr, + default="skyline.log", +) + secret_key = Opt( name="secret_key", description="Secret key", @@ -115,6 +122,7 @@ GROUP_NAME = __name__.split(".")[-1] ALL_OPTS = ( debug, log_dir, + log_file, secret_key, access_token_expire, access_token_renew, diff --git a/skyline_apiserver/main.py b/skyline_apiserver/main.py index 9d03d48..e965cc0 100644 --- a/skyline_apiserver/main.py +++ b/skyline_apiserver/main.py @@ -32,7 +32,7 @@ PROJECT_NAME = "Skyline API" async def on_startup() -> None: configure("skyline") log_setup( - Path(CONF.default.log_dir).joinpath("skyline", "skyline-apiserver.log"), + Path(CONF.default.log_dir).joinpath(CONF.default.log_file), debug=CONF.default.debug, ) policies_setup() diff --git a/skyline_apiserver/templates/nginx.conf.j2 b/skyline_apiserver/templates/nginx.conf.j2 index 40bb97d..11f0bbc 100644 --- a/skyline_apiserver/templates/nginx.conf.j2 +++ b/skyline_apiserver/templates/nginx.conf.j2 @@ -44,8 +44,8 @@ http { '"$upstream_response_time" "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log {{ log_dir | default('/var/log') }}/skyline/nginx_access.log main; - error_log {{ log_dir | default('/var/log') }}/skyline/nginx_error.log; + access_log {{ log_dir | default('/var/log/skyline') }}/skyline-nginx-access.log main; + error_log {{ log_dir | default('/var/log/skyline') }}/skyline-nginx-error.log; ## # Gzip Settings