forked from kubectyl/sftp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (37 loc) · 1.04 KB
/
main.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
package main
import (
"net/http"
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/multi"
"github.com/apex/log/handlers/text"
"github.com/kubectyl/kuber/remote"
"github.com/kubectyl/sftp-server/config"
"github.com/kubectyl/sftp-server/sftp"
)
// Configures the global logger for Zap so that we can call it from any location
// in the code without having to pass around a logger instance.
func initLogging() {
log.SetLevel(log.InfoLevel)
if config.Get().Debug {
log.SetLevel(log.DebugLevel)
}
log.SetHandler(multi.New(text.New(os.Stdout)))
log.Info("writing log file to disk")
}
func main() {
initLogging()
pclient := remote.New(
config.Get().PanelLocation,
remote.WithCredentials(config.Get().AuthenticationTokenId, config.Get().AuthenticationToken),
remote.WithHttpClient(&http.Client{
Timeout: time.Second * time.Duration(config.Get().RemoteQuery.Timeout),
}),
)
// Run the SFTP server.
if err := sftp.New(pclient).Run(); err != nil {
log.WithError(err).Fatal("failed to initialize the sftp server")
return
}
}