5 Commits

Author SHA1 Message Date
fauno 3e25cf532a v0.5.2 2023-04-20 11:40:30 -03:00
fauno 7cb89e1df8 fix: support postgres:// too 2023-04-20 11:40:19 -03:00
fauno 544b188994 feat: log parsing exceptions 2023-04-20 11:39:05 -03:00
fauno 476b4dce00 v0.5.1 2023-04-11 15:49:21 -03:00
fauno 32edf9b5d5 fix: no www-data, only nobody 2023-04-11 15:34:21 -03:00
3 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -7,5 +7,5 @@ test -n "$ACCESS_LOGS_FLAGS" || exit 1
umask 007
# Read from fifo and load into database
daemonize -p /run/access_logd.pid -u nobody -g www-data \
daemonize -p /run/access_logd.pid -u nobody \
/usr/bin/access_log $ACCESS_LOGS_FLAGS
+1 -1
View File
@@ -1,5 +1,5 @@
name: "access_log"
version: "0.5.0"
version: "0.5.1"
authors:
- "f <f@sutty.nl>"
targets:
+7 -3
View File
@@ -1,3 +1,4 @@
require "log"
require "file_utils"
require "json"
require "socket"
@@ -9,7 +10,9 @@ require "./models/access_log"
require "./models/crawler"
require "./swd"
VERSION = "0.5.0"
VERSION = "0.5.2"
Log.setup_from_env
# Default socket location
socket = "/tmp/access_log.socket"
@@ -82,7 +85,7 @@ OptionParser.parse do |p|
end
# Parameterize values according to database URI
if database.starts_with? "postgresql://"
if database.starts_with?("postgresql://") || database.starts_with?("postgres://")
params = fields.map_with_index do |_, i|
"$#{i + 1}"
end
@@ -187,7 +190,8 @@ db = DB.open database do |db|
(swd ? s.try(&.total_co2) : nil)
# Ignore parsing errors
rescue JSON::ParseException
rescue e : JSON::ParseException
Log.warn &.emit("Parse exception", error: e.message)
rescue IO::Error
server.close
FileUtils.rm(socket) if File.exists? socket