Skip to content

Commit 2133d4f

Browse files
committed
fix up log file stuff
1 parent b8fe10e commit 2133d4f

File tree

6 files changed

+51
-37
lines changed

6 files changed

+51
-37
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
name: build-and-release
22
on:
33
push:
4-
branches: [ 'main' ]
54
tags: [ 'v*.*.*' ]
65
pull_request:
7-
branches: [ 'main' ]
6+
branches: [ 'main', 'unstable' ]
87

98
permissions:
109
contents: read
1110

1211
jobs:
1312
release:
14-
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
1513
outputs:
1614
version: ${{ steps.release.outputs.version }}
1715
name: Make Release Assets
@@ -42,7 +40,7 @@ jobs:
4240
name: release
4341
path: release
4442

45-
deploy-nonpublic-packagecloud:
43+
deploy-release-packagecloud:
4644
if: startsWith(github.ref, 'refs/tags/v')
4745
needs: release
4846
name: Deploy Nonpublic PackageCloud
@@ -54,7 +52,23 @@ jobs:
5452
name: release
5553
- uses: golift/upload-packagecloud@v1.1
5654
with:
57-
userrepo: golift/nonpublic
55+
userrepo: golift/pkgs
56+
apitoken: ${{ secrets.PACKAGECLOUD_TOKEN }}
57+
packages: .
58+
debdists: ubuntu/focal
59+
deploy-unstable-packagecloud:
60+
if: github.ref == 'refs/heads/unstable'
61+
needs: release
62+
name: Deploy Unstable PackageCloud
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Download release files
66+
uses: actions/download-artifact@v8
67+
with:
68+
name: release
69+
- uses: golift/upload-packagecloud@v1.1
70+
with:
71+
userrepo: golift/unstable
5872
apitoken: ${{ secrets.PACKAGECLOUD_TOKEN }}
5973
packages: .
6074
debdists: ubuntu/focal

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ function socket_put_contents($socket, $outputfile, $line, $host, $length = 8000)
6565

6666
## Usage
6767

68-
We run this from a Docker container directly on a Synology NAS. Using this image:<br/>
69-
`ghcr.io/Notifiarr/fogwillow:main`
68+
We run this from a Docker container directly on a Synology NAS. Using this image:
69+
70+
- `ghcr.io/Notifiarr/fogwillow:main`
7071

7172
Mount `/config` and give it a `/config/fog.conf` file that looks like the
7273
[example](https://github.com/Notifiarr/fogwillow/blob/main/fog.conf).

fog.conf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Example Fog Willow config file.
22
## The values below are the defaults.
3-
#####################################
3+
## https://github.com/Notifiarr/fogwillow
4+
############################################
45

56
# FW_PASSWORD: If a password is set then clients must send it as a setting.
67
password = ""
@@ -12,12 +13,12 @@ flush_interval = "16s"
1213
group_interval = "4s"
1314
# FW_OUTPUT_PATH: This is prefixed to whatever comes in over the wire.
1415
output_path = "/tmp"
15-
# FW_LOG_FILE: This should be a full path, probably /config/fog.log.
16+
# FW_LOG_FILE: This should be a full path, probably /config/fog.log or /etc/fogwillow/fog.log.
1617
log_file = ""
17-
# FW_LOG_FILE_MB: Size of each log file.
18-
log_file_mb = 0
19-
# FW_LOG_FILES: How many logs files to keep around.
20-
log_files = 0
18+
# FW_LOG_FILE_MB: Size of each log file. Default is 0 if this is omitted, rotation disabled.
19+
log_file_mb = 5
20+
# FW_LOG_FILES: How many logs files to keep around. Default is 0 if this is omitted, rotation disabled.
21+
log_files = 30
2122
# FW_BUFFER_UDP: This is the UDP socket buffer in bytes.
2223
buffer_udp = 4194304 # 4MB
2324
# FW_BUFFER_PACKET: This is the size of the read buffer per packet.
@@ -56,6 +57,6 @@ tls_key_path = ""
5657
# FW_HTTP_SERVER_ACCESS_LOG: Path to the HTTP access log file (Apache Combined format). Leave empty to disable.
5758
access_log = ""
5859
# FW_HTTP_SERVER_ACCESS_LOG_MB: Maximum size of each access log file in MB. 0 means unlimited, no file rotation.
59-
access_log_mb = 4 # 4MB
60+
access_log_mb = 5 # 5MB
6061
# FW_HTTP_SERVER_ACCESS_LOG_FILES: Number of rotated access log files to keep. 0 means keep all.
61-
access_log_files = 10 # 10 files.
62+
access_log_files = 30 # 30 files.

pkg/fog/start.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const (
2424
DefaultUDPBuffer = 1 << 22 // 4MB
2525
DefaultPacketBuffer = 1 << 18 // 256KB
2626
DefaultChanBuffer = 1 << 15 // 32 thousand
27-
MaxStupidValue = uint(9999999)
2827
)
2928

3029
// Config is the input _and_ running data.
@@ -118,32 +117,32 @@ func (c *Config) Start() error {
118117
// setup makes sure configurations are sound and sane.
119118
func (c *Config) setup() {
120119
// Protect uint->int64 conversions.
121-
if c.LogFileMB > MaxStupidValue {
122-
c.LogFileMB = MaxStupidValue
120+
if c.LogFileMB > httpserver.MaxStupidValue {
121+
c.LogFileMB = httpserver.MaxStupidValue
123122
}
124123

125-
if c.LogFiles > MaxStupidValue {
126-
c.LogFiles = MaxStupidValue
124+
if c.LogFiles > httpserver.MaxStupidValue {
125+
c.LogFiles = httpserver.MaxStupidValue
127126
}
128127

129-
if c.HTTPServer.AccessLogMB > MaxStupidValue {
130-
c.HTTPServer.AccessLogMB = MaxStupidValue
128+
if c.HTTPServer.AccessLogMB > httpserver.MaxStupidValue {
129+
c.HTTPServer.AccessLogMB = httpserver.MaxStupidValue
131130
}
132131

133-
if c.HTTPServer.AccessLogFiles > MaxStupidValue {
134-
c.HTTPServer.AccessLogFiles = MaxStupidValue
132+
if c.HTTPServer.AccessLogFiles > httpserver.MaxStupidValue {
133+
c.HTTPServer.AccessLogFiles = httpserver.MaxStupidValue
135134
}
136135

137136
if c.Processors < 1 {
138137
c.Processors = 1
139-
} else if c.Processors > MaxStupidValue {
140-
c.Processors = MaxStupidValue
138+
} else if c.Processors > httpserver.MaxStupidValue {
139+
c.Processors = httpserver.MaxStupidValue
141140
}
142141

143142
if c.Listeners < 1 {
144143
c.Listeners = 1
145-
} else if c.Listeners > MaxStupidValue {
146-
c.Listeners = MaxStupidValue
144+
} else if c.Listeners > httpserver.MaxStupidValue {
145+
c.Listeners = httpserver.MaxStupidValue
147146
}
148147

149148
if c.newBuf = buf.NewBuffer; c.BufferPool {

pkg/httpserver/accesslog.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ const (
1414
LogFileMode = 0o644
1515
// Apache Combined Log Format: host ident user time "request" status bytes "referer" "user-agent".
1616
CombinedLogFormat = `%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"`
17+
MaxStupidValue = uint(9999999) // for comparing with config.
1718
)
1819

1920
// newAccessLog creates a rotating access log writer from config.
2021
// Returns nil when AccessLog is empty, disabling access logging.
2122
func newAccessLog(config *Config) *rotatorr.Logger {
22-
if config.AccessLog == "" || config.AccessLogMB < 0 || config.AccessLogFiles < 0 {
23+
if config.AccessLog == "" {
2324
return nil
2425
}
2526

2627
return rotatorr.NewMust(&rotatorr.Config{
2728
Filepath: config.AccessLog,
28-
FileSize: config.AccessLogMB * OneMB,
29+
FileSize: int64(config.AccessLogMB * OneMB), //nolint:gosec // size is protected by config.
2930
FileMode: LogFileMode,
3031
Rotatorr: &timerotator.Layout{
31-
FileCount: config.AccessLogFiles,
32+
FileCount: int(config.AccessLogFiles), //nolint:gosec // count is protected by config.
3233
},
3334
})
3435
}

pkg/httpserver/config.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ const (
1010
DefaultWriteTimeout = 10 * time.Second
1111
DefaultIdleTimeout = 120 * time.Second
1212
DefaultMaxHeaderBytes = 1 << 16 // 64KB
13-
DefaultAccessLogMB = 1 << 22 // 4MB
14-
DefaultAccessLogFiles = 10 // 10 files
1513
OneMB = 1 << 20 // 1 MB, used for calculations.
1614
)
1715

@@ -68,11 +66,11 @@ func (c *Config) Setup() {
6866
c.MaxHeaderBytes = DefaultMaxHeaderBytes
6967
}
7068

71-
if c.AccessLogFiles == 0 {
72-
c.AccessLogFiles = DefaultAccessLogFiles
69+
if c.AccessLogFiles > MaxStupidValue {
70+
c.AccessLogFiles = MaxStupidValue
7371
}
7472

75-
if c.AccessLogMB == 0 {
76-
c.AccessLogMB = DefaultAccessLogMB
73+
if c.AccessLogMB > MaxStupidValue {
74+
c.AccessLogMB = MaxStupidValue
7775
}
7876
}

0 commit comments

Comments
 (0)