From d71075dfedf4c184675a5acbb6518b7c61f2e67f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 3 Oct 2019 20:42:48 +0200 Subject: [PATCH] Make sure ssowat log file is created and exists when starting nginx/ssowat --- init.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index d4efe1f..6993e53 100644 --- a/init.lua +++ b/init.lua @@ -8,6 +8,10 @@ -- another. -- +-- Path of the configuration +conf_path = "/etc/ssowat/conf.json" +log_file = "/var/log/nginx/ssowat.log" + -- Remove prepending '@' & trailing 'init.lua' script_path = string.sub(debug.getinfo(1).source, 2, -9) @@ -23,6 +27,11 @@ local socket = require "socket" local config = require "config" lustache = require "lustache" +-- Make sure the log file exists and we can write in it +io.popen("touch "..log_file) +io.popen("chown www-data "..log_file) +io.popen("chmod u+w "..log_file) + -- Persistent shared table flashs = {} i18n = {} @@ -54,8 +63,5 @@ for file in lfs.dir(locale_dir) do end end --- Path of the configuration -conf_path = "/etc/ssowat/conf.json" - -- You should see that in your Nginx error logs by default ngx.log(ngx.INFO, "SSOwat ready")