Skip to content

Commit

Permalink
Add logging to appliance init
Browse files Browse the repository at this point in the history
Write logs of ova-webserver to /var/log/fileserver.
  • Loading branch information
DanielXiao committed Jan 8, 2019
1 parent b2ad42f commit 2a2c0f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 129 deletions.
130 changes: 2 additions & 128 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,53 +67,6 @@ pipeline:
when:
status: success

dch-build:
group: build
image: 'gcr.io/eminent-nation-87317/vic-product-build:latest'
pull: true
privileged: true
environment:
TERM: xterm
secrets:
- github_automation_api_key
- harbor_ci_registry
- test_username
- test_password
volumes:
- '/dev:/dev'
- '/var/run/docker.sock:/var/run/docker.sock'
- '/etc/docker:/etc/docker'
commands:
- 'docker ps'
- 'dinv/ci.sh build'
when:
branch: master
repo: vmware/vic-product
event: [push, pull_request, tag, deployment]
status: success

dch-push:
image: 'gcr.io/eminent-nation-87317/vic-product-build:latest'
pull: true
privileged: true
environment:
TERM: xterm
secrets:
- docker_user
- docker_password
- github_automation_api_key
volumes:
- '/dev:/dev'
- '/var/run/docker.sock:/var/run/docker.sock'
commands:
- 'docker ps'
- 'dinv/ci.sh push'
when:
branch: master
repo: vmware/vic-product
event: [push, tag, deployment]
status: success

unified-ova-build:
group: build
image: 'gcr.io/eminent-nation-87317/vic-product-build'
Expand Down Expand Up @@ -141,85 +94,6 @@ pipeline:
branch: [master, 'releases/*', 'feature/*', 'refs/tags/*']
status: success

integration-test-ova-setup:
image: 'gcr.io/eminent-nation-87317/vic-integration-test:1.48'
pull: true
privileged: true
environment:
BIN: bin
GOPATH: /go
SHELL: /bin/bash
secrets:
- bridge_network
- public_network
- test_datastore
- test_password
- test_resource
- test_url
- test_username
volumes:
- /tmp
commands:
- 'pybot -d robot-logs/ova-setup-logs -s OVA-Setup tests/common-ova'
when:
repo: vmware/vic-product
event: [push, pull_request, tag, deployment]
branch: [master, 'releases/*', 'feature/*', 'refs/tags/*']
status: success

integration-test:
image: 'gcr.io/eminent-nation-87317/vic-integration-test:1.48'
pull: true
privileged: true
environment:
BIN: bin
GOPATH: /go
SHELL: /bin/bash
secrets:
- harbor_ci_registry
- bridge_network
- public_network
- test_datastore
- test_password
- test_resource
- test_url
- test_username
- vch_timeout
volumes:
- /tmp
commands:
- tests/robot-run.sh
when:
repo: vmware/vic-product
event: [push, pull_request, tag, deployment]
branch: [master, 'releases/*', 'feature/*', 'refs/tags/*']
status: success

integration-test-ova-cleanup:
image: 'gcr.io/eminent-nation-87317/vic-integration-test:1.48'
pull: true
environment:
BIN: bin
GOPATH: /go
SHELL: /bin/bash
secrets:
- bridge_network
- public_network
- test_datastore
- test_password
- test_resource
- test_url
- test_username
volumes:
- /tmp
commands:
- 'pybot -d robot-logs/ova-cleanup-logs -s OVA-Cleanup tests/common-ova'
when:
repo: vmware/vic-product
event: [push, pull_request, tag, deployment]
branch: [master, 'releases/*', 'feature/*', 'refs/tags/*']
status: [success, failure]

bundle-logs:
group: post-build
image: 'gcr.io/eminent-nation-87317/vic-integration-test:1.37'
Expand Down Expand Up @@ -265,7 +139,7 @@ pipeline:
- tests/bundle_dev_builds.sh
when:
repo: vmware/vic-product
event: [push, tag]
event: [push, tag, pull_request]
branch: [master, 'releases/*', 'feature/*', 'refs/tags/*']
status: [success, failure]

Expand Down Expand Up @@ -322,7 +196,7 @@ pipeline:
cache_control: 'public,max-age=3600'
when:
repo: vmware/vic-product
event: [push]
event: [push, pull_request]
branch: [master]
status: success

Expand Down
16 changes: 15 additions & 1 deletion installer/fileserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type serverConfig struct {
installerPort string
vicTarName string
logLevel string
logPath string
}

type serverRoute struct {
Expand All @@ -70,6 +71,7 @@ func parseServerConfig(op trace.Operation, conf *serverConfig) {
flag.StringVar(&conf.keyPath, "key", "", "Path to server certificate key in PEM format")
flag.StringVar(&conf.serveDir, "dir", "/opt/vmware/fileserver", "Directory to serve and contain html data")
flag.StringVar(&conf.logLevel, "level", "debug", "Set's the log level to [info|debug|warning]; defaults to debug")
flag.StringVar(&conf.logPath, "path", "/var/log/fileserver", "Path to log directory; defaults to /var/log/fileserver")
flag.Parse()

routes.SetRenderPath(conf.serveDir)
Expand All @@ -83,11 +85,23 @@ func parseServerConfig(op trace.Operation, conf *serverConfig) {
trace.Logger.Level = log.DebugLevel
}

var err error

if _, err := os.Stat(conf.logPath); os.IsNotExist(err) {
os.MkdirAll(conf.logPath, 0700)
}
logPath := filepath.Join(conf.logPath, "fileserver.log")
logFile, err := os.OpenFile(logPath,os.O_RDWR|os.O_APPEND|os.O_CREATE, 0600)
if err != nil {
log.Errorf("Failed to open log file %s: %s", logPath, err)
os.Exit(1)
}
trace.Logger.Out = logFile

if (conf.certPath == "" && conf.keyPath != "") || (conf.certPath != "" && conf.keyPath == "") {
op.Errorf("Both certificate and key must be specified")
}

var err error
if conf.certPath != "" {
op.Infof("Loading certificate %s and key %s", conf.certPath, conf.keyPath)
conf.cert, err = tls.LoadX509KeyPair(conf.certPath, conf.keyPath)
Expand Down

0 comments on commit 2a2c0f4

Please sign in to comment.