Skip to content

Commit

Permalink
feat: add server log rotation (#1304)
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Brecic <[email protected]>
  • Loading branch information
lbrecic authored Nov 15, 2024
1 parent d5f75b7 commit 59fa89a
Show file tree
Hide file tree
Showing 22 changed files with 821 additions and 96 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ require (
google.golang.org/grpc v1.66.0
google.golang.org/protobuf v1.34.2
gopkg.in/ini.v1 v1.67.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gorm.io/gorm v1.25.11
tailscale.com v1.72.1
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 1 addition & 1 deletion internal/testing/agent/mocks/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewMockRestServer(t *testing.T, workspace *workspace.Workspace) *httptest.S
ApiPort: 3000,
HeadscalePort: 4000,
BinariesPath: "",
LogFilePath: "",
LogFile: nil,
})
})
serverController.POST("/network-key", func(ctx *gin.Context) {
Expand Down
35 changes: 32 additions & 3 deletions pkg/api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,35 @@ const docTemplate = `{
}
}
},
"LogFileConfig": {
"type": "object",
"required": [
"maxAge",
"maxBackups",
"maxSize",
"path"
],
"properties": {
"compress": {
"type": "boolean"
},
"localTime": {
"type": "boolean"
},
"maxAge": {
"type": "integer"
},
"maxBackups": {
"type": "integer"
},
"maxSize": {
"type": "integer"
},
"path": {
"type": "string"
}
}
},
"NetworkKey": {
"type": "object",
"required": [
Expand Down Expand Up @@ -2793,7 +2822,7 @@ const docTemplate = `{
"id",
"localBuilderRegistryImage",
"localBuilderRegistryPort",
"logFilePath",
"logFile",
"providersDir",
"registryUrl",
"serverDownloadUrl"
Expand Down Expand Up @@ -2835,8 +2864,8 @@ const docTemplate = `{
"localBuilderRegistryPort": {
"type": "integer"
},
"logFilePath": {
"type": "string"
"logFile": {
"$ref": "#/definitions/LogFileConfig"
},
"providersDir": {
"type": "string"
Expand Down
35 changes: 32 additions & 3 deletions pkg/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,35 @@
}
}
},
"LogFileConfig": {
"type": "object",
"required": [
"maxAge",
"maxBackups",
"maxSize",
"path"
],
"properties": {
"compress": {
"type": "boolean"
},
"localTime": {
"type": "boolean"
},
"maxAge": {
"type": "integer"
},
"maxBackups": {
"type": "integer"
},
"maxSize": {
"type": "integer"
},
"path": {
"type": "string"
}
}
},
"NetworkKey": {
"type": "object",
"required": [
Expand Down Expand Up @@ -2790,7 +2819,7 @@
"id",
"localBuilderRegistryImage",
"localBuilderRegistryPort",
"logFilePath",
"logFile",
"providersDir",
"registryUrl",
"serverDownloadUrl"
Expand Down Expand Up @@ -2832,8 +2861,8 @@
"localBuilderRegistryPort": {
"type": "integer"
},
"logFilePath": {
"type": "string"
"logFile": {
"$ref": "#/definitions/LogFileConfig"
},
"providersDir": {
"type": "string"
Expand Down
26 changes: 23 additions & 3 deletions pkg/api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,26 @@ definitions:
- downloadUrls
- name
type: object
LogFileConfig:
properties:
compress:
type: boolean
localTime:
type: boolean
maxAge:
type: integer
maxBackups:
type: integer
maxSize:
type: integer
path:
type: string
required:
- maxAge
- maxBackups
- maxSize
- path
type: object
NetworkKey:
properties:
key:
Expand Down Expand Up @@ -656,8 +676,8 @@ definitions:
type: string
localBuilderRegistryPort:
type: integer
logFilePath:
type: string
logFile:
$ref: '#/definitions/LogFileConfig'
providersDir:
type: string
registryUrl:
Expand All @@ -677,7 +697,7 @@ definitions:
- id
- localBuilderRegistryImage
- localBuilderRegistryPort
- logFilePath
- logFile
- providersDir
- registryUrl
- serverDownloadUrl
Expand Down
1 change: 1 addition & 0 deletions pkg/apiclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Class | Method | HTTP request | Description
- [GitStatus](docs/GitStatus.md)
- [GitUser](docs/GitUser.md)
- [InstallProviderRequest](docs/InstallProviderRequest.md)
- [LogFileConfig](docs/LogFileConfig.md)
- [NetworkKey](docs/NetworkKey.md)
- [PrebuildConfig](docs/PrebuildConfig.md)
- [PrebuildDTO](docs/PrebuildDTO.md)
Expand Down
41 changes: 37 additions & 4 deletions pkg/apiclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,33 @@ components:
- downloadUrls
- name
type: object
LogFileConfig:
example:
localTime: true
path: path
compress: true
maxAge: 5
maxBackups: 2
maxSize: 7
properties:
compress:
type: boolean
localTime:
type: boolean
maxAge:
type: integer
maxBackups:
type: integer
maxSize:
type: integer
path:
type: string
required:
- maxAge
- maxBackups
- maxSize
- path
type: object
NetworkKey:
example:
key: key
Expand Down Expand Up @@ -2367,7 +2394,13 @@ components:
buildImageNamespace: buildImageNamespace
serverDownloadUrl: serverDownloadUrl
binariesPath: binariesPath
logFilePath: logFilePath
logFile:
localTime: true
path: path
compress: true
maxAge: 5
maxBackups: 2
maxSize: 7
samplesIndexUrl: samplesIndexUrl
defaultProjectImage: defaultProjectImage
providersDir: providersDir
Expand Down Expand Up @@ -2401,8 +2434,8 @@ components:
type: string
localBuilderRegistryPort:
type: integer
logFilePath:
type: string
logFile:
$ref: '#/components/schemas/LogFileConfig'
providersDir:
type: string
registryUrl:
Expand All @@ -2422,7 +2455,7 @@ components:
- id
- localBuilderRegistryImage
- localBuilderRegistryPort
- logFilePath
- logFile
- providersDir
- registryUrl
- serverDownloadUrl
Expand Down
Loading

0 comments on commit 59fa89a

Please sign in to comment.