-
Notifications
You must be signed in to change notification settings - Fork 103
/
log-courier.go
75 lines (61 loc) · 2.52 KB
/
log-courier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright 2012-2020 Jason Woods and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"flag"
"github.com/driskell/log-courier/lc-lib/admin"
"github.com/driskell/log-courier/lc-lib/core"
"github.com/driskell/log-courier/lc-lib/prospector"
"github.com/driskell/log-courier/lc-lib/publisher"
"github.com/driskell/log-courier/lc-lib/spooler"
"github.com/driskell/log-courier/lc-lib/stdinharvester"
_ "github.com/driskell/log-courier/lc-lib/codecs/filter"
_ "github.com/driskell/log-courier/lc-lib/codecs/multiline"
_ "github.com/driskell/log-courier/lc-lib/codecs/plain"
"github.com/driskell/log-courier/lc-lib/transports/tcp/courier"
_ "github.com/driskell/log-courier/lc-lib/transports/test"
)
// Generate platform-specific default configuration values
//go:generate go run lc-lib/config/generate/platform.go platform main config.DefaultConfigurationFile prospector.DefaultGeneralPersistDir admin.DefaultAdminBind
var (
app *core.App
stdin bool
fromBeginning bool
)
func main() {
courier.SetClientName("LCOR")
app = core.NewApp("Log Courier", core.LogCourierVersion)
flag.BoolVar(&stdin, "stdin", false, "Read from stdin instead of files listed in the config file")
flag.BoolVar(&fromBeginning, "from-beginning", false, "On first run, read new files from the beginning instead of the end")
app.StartUp()
// Skip admin if reading from stdin
if !stdin && app.Config().Section("admin").(*admin.Config).Enabled {
app.Pipeline().AddService(admin.NewServer(app))
}
if stdin {
// If reading from stdin, don't start prospector, directly start a harvester
app.Pipeline().AddSource(stdinharvester.New(app))
} else {
// Prospector will handle new files, start harvesters, and own the registrar
app.Pipeline().AddSource(prospector.NewProspector(app, fromBeginning))
}
// Add spooler as first processor, it combines into larger chunks as needed
app.Pipeline().AddProcessor(spooler.NewSpooler(app))
// Create sink
app.Pipeline().SetSink(publisher.NewPublisher())
// Go!
app.Run()
}