This is an automated email from the ASF dual-hosted git repository.

rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 7d19756  check for missing cert files before starting (#3480)
7d19756 is described below

commit 7d197567cf7e0480ca2e5d76c93bce6ac2b7b8e6
Author: Dan Kirkwood <[email protected]>
AuthorDate: Fri Apr 12 09:14:38 2019 -0600

    check for missing cert files before starting (#3480)
---
 .../traffic_ops_golang/traffic_ops_golang.go       | 32 +++++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go 
b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
index 504941d..7b1f834 100644
--- a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
+++ b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
@@ -153,9 +153,33 @@ func main() {
        }
 
        go func() {
+               if cfg.KeyPath == "" {
+                       log.Errorf("key cannot be blank in %s", 
cfg.ConfigHypnotoad.Listen)
+                       os.Exit(1)
+               }
+
+               if cfg.CertPath == "" {
+                       log.Errorf("cert cannot be blank in %s", 
cfg.ConfigHypnotoad.Listen)
+                       os.Exit(1)
+               }
+
+               if file, err := os.Open(cfg.CertPath); err != nil {
+                       log.Errorf("cannot open %s for read: %s", cfg.CertPath, 
err.Error())
+                       os.Exit(1)
+               } else {
+                       file.Close()
+               }
+
+               if file, err := os.Open(cfg.KeyPath); err != nil {
+                       log.Errorf("cannot open %s for read: %s", cfg.KeyPath, 
err.Error())
+                       os.Exit(1)
+               } else {
+                       file.Close()
+               }
+
                if err := server.ListenAndServeTLS(cfg.CertPath, cfg.KeyPath); 
err != nil {
                        log.Errorf("stopping server: %v\n", err)
-                       panic(err)
+                       os.Exit(1)
                }
        }()
 
@@ -172,12 +196,12 @@ func main() {
        }
 
        reloadProfilingConfig := func() {
-               SetNewProfilingInfo(*configFileName, &profiling, 
&profilingLocation, cfg.Version)
+               setNewProfilingInfo(*configFileName, &profiling, 
&profilingLocation, cfg.Version)
        }
        signalReloader(unix.SIGHUP, reloadProfilingConfig)
 }
 
-func SetNewProfilingInfo(configFileName string, currentProfilingEnabled *bool, 
currentProfilingLocation *string, version string) {
+func setNewProfilingInfo(configFileName string, currentProfilingEnabled *bool, 
currentProfilingLocation *string, version string) {
        newProfilingEnabled, newProfilingLocation, err := 
reloadProfilingInfo(configFileName)
        if err != nil {
                log.Errorln("reloading config: ", err.Error())
@@ -215,7 +239,7 @@ func getProcessedProfilingLocation(rawProfilingLocation 
string, errorLogLocation
                if _, err := os.Stat(profilingLocation); err != nil {
                        err = os.Mkdir(profilingLocation, 0755)
                        if err != nil {
-                               return "", fmt.Errorf("unable to create 
profiling location: %s\n", err.Error())
+                               return "", fmt.Errorf("unable to create 
profiling location: %s", err.Error())
                        }
                }
        }

Reply via email to