2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Copyright 2014 Unknwon  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Copyright 2014 Torkel Ödegaard  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  setting  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"bytes" 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-12 13:31:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"fmt" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"net/url" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"os" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"path" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"path/filepath" 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"regexp" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									"runtime" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"strings" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"gopkg.in/ini.v1" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-11 22:00:49 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/go-macaron/session" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-05 10:37:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/log" 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 09:14:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/util" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  Scheme  string  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  (  
						 
					
						
							
								
									
										
										
										
											2016-11-23 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									HTTP               Scheme  =  "http" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HTTPS              Scheme  =  "https" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DEFAULT_HTTP_ADDR  string  =  "0.0.0.0" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-12-16 12:04:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DEV   string  =  "development" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PROD  string  =  "production" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									TEST  string  =  "test" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								var  (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// App settings. 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-02 14:32:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Env           string  =  DEV 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AppUrl        string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AppSubUrl     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									InstanceName  string 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-05 10:46:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// build 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BuildVersion  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BuildCommit   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BuildStamp    int64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Paths 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-08 13:22:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LogsPath        string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HomePath        string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DataPath        string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PluginsPath     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CustomInitPath  =  "conf/custom.ini" 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Log settings. 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LogModes    [ ] string 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 09:29:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LogConfigs  [ ] util . DynMap 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Http server options 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Protocol            Scheme 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Domain              string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HttpAddr ,  HttpPort  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SshPort             int 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CertFile ,  KeyFile   string 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									RouterLogging       bool 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-11 07:51:46 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DataProxyLogging    bool 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									StaticRootPath      string 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-14 10:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									EnableGzip          bool 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-05 11:21:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									EnforceDomain       bool 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Security settings. 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-05 11:08:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SecretKey              string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LogInRememberDays      int 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CookieUserName         string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CookieRememberName     string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DisableGravatar        bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									EmailCodeValidMinutes  int 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 17:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DataProxyWhiteList     map [ string ] bool 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-14 17:39:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Snapshots 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-23 16:56:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExternalSnapshotUrl    string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExternalSnapshotName   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExternalEnabled        bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SnapShotTTLDays        int 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SnapShotRemoveExpired  bool 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-14 17:39:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-11 16:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// User settings 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-31 11:35:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AllowUserSignUp     bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AllowUserOrgCreate  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AutoAssignOrg       bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AutoAssignOrgRole   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									VerifyEmailEnabled  bool 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-20 11:15:36 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LoginHint           string 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-12 15:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DefaultTheme        string 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-28 15:27:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DisableLoginForm    bool 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 15:14:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-07 16:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Http auth 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 15:45:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AdminUser      string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AdminPassword  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-23 20:07:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AnonymousEnabled  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AnonymousOrgName  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AnonymousOrgRole  string 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-07 16:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 11:55:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Auth proxy settings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyEnabled         bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyHeaderName      string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyHeaderProperty  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyAutoSignUp      bool 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-23 14:22:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AuthProxyLdapSyncTtl     int 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyWhitelist       string 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 11:55:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 09:37:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Basic Auth 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BasicAuthEnabled  bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Session settings. 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-30 10:28:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions  session . Options 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Global setting objects. 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Cfg           * ini . File 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									ConfRootPath  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									IsWindows     bool 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-06 15:31:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// PhantomJs Rendering 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-28 21:06:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ImagesDir   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PhantomDir  string 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// for logging purposes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									configFiles                   [ ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									appliedCommandLineProperties  [ ] string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									appliedEnvOverrides           [ ] string 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-22 15:14:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-21 09:30:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ReportingEnabled    bool 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-11 12:21:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CheckForUpdates     bool 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-21 09:30:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GoogleAnalyticsId   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GoogleTagManagerId  string 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-04 09:34:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// LDAP 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-07 01:49:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LdapEnabled      bool 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LdapConfigFile   string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LdapAllowSignup  bool  =  true 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-10 11:10:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-04 14:29:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// SMTP email settings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Smtp  SmtpSettings 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 01:47:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// QUOTA 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Quota  QuotaSettings 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-29 14:35:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Alerting 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-25 13:32:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AlertingEnabled  bool 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-20 10:43:29 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExecuteAlerts    bool 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 13:31:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 09:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// logger 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									logger  log . Logger 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-16 08:06:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-27 13:52:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Grafana.NET URL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GrafanaNetUrl  string 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-30 13:36:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// S3 temp image store 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									S3TempImageStoreBucketUrl  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									S3TempImageStoreAccessKey  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									S3TempImageStoreSecretKey  string 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-10 17:27:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ImageUploadProvider  string 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-08 14:10:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								type  CommandLineArgs  struct  {  
						 
					
						
							
								
									
										
										
										
											2015-04-12 09:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Config    string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HomePath  string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Args      [ ] string 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-08 14:10:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func  init ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									IsWindows  =  runtime . GOOS  ==  "windows" 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 09:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger  =  log . New ( "settings" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-01 15:29:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  parseAppUrlAndSubUrl ( section  * ini . Section )  ( string ,  string )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									appUrl  :=  section . Key ( "root_url" ) . MustString ( "http://localhost:3000/" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  appUrl [ len ( appUrl ) - 1 ]  !=  '/'  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										appUrl  +=  "/" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Check if has app suburl. 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-30 14:21:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									url ,  err  :=  url . Parse ( appUrl ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										log . Fatal ( 4 ,  "Invalid root_url(%s): %s" ,  appUrl ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									appSubUrl  :=  strings . TrimSuffix ( url . Path ,  "/" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  appUrl ,  appSubUrl 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-06 14:17:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ToAbsUrl ( relativeUrl  string )  string  {  
						 
					
						
							
								
									
										
										
										
											2015-02-04 11:35:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  AppUrl  +  relativeUrl 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-01 13:50:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  shouldRedactKey ( s  string )  bool  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uppercased  :=  strings . ToUpper ( s ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-27 00:50:35 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  strings . Contains ( uppercased ,  "PASSWORD" )  ||  strings . Contains ( uppercased ,  "SECRET" )  ||  strings . Contains ( uppercased ,  "PROVIDER_CONFIG" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-01 13:50:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 18:37:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  shouldRedactURLKey ( s  string )  bool  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uppercased  :=  strings . ToUpper ( s ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  strings . Contains ( uppercased ,  "DATABASE_URL" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  applyEnvVariableOverrides ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									appliedEnvOverrides  =  make ( [ ] string ,  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-12 13:31:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  _ ,  section  :=  range  Cfg . Sections ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  key  :=  range  section . Keys ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											sectionName  :=  strings . ToUpper ( strings . Replace ( section . Name ( ) ,  "." ,  "_" ,  - 1 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											keyName  :=  strings . ToUpper ( strings . Replace ( key . Name ( ) ,  "." ,  "_" ,  - 1 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											envKey  :=  fmt . Sprintf ( "GF_%s_%s" ,  sectionName ,  keyName ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											envValue  :=  os . Getenv ( envKey ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  len ( envValue )  >  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												key . SetValue ( envValue ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-01 13:50:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  shouldRedactKey ( envKey )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-04 10:38:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													envValue  =  "*********" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-28 18:37:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  shouldRedactURLKey ( envKey )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													u ,  _  :=  url . Parse ( envValue ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													ui  :=  u . User 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ui  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														_ ,  exists  :=  ui . Password ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														if  exists  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															u . User  =  url . UserPassword ( ui . Username ( ) ,  "-redacted-" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															envValue  =  u . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												appliedEnvOverrides  =  append ( appliedEnvOverrides ,  fmt . Sprintf ( "%s=%s" ,  envKey ,  envValue ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-12 13:31:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-12 11:55:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  applyCommandLineDefaultProperties ( props  map [ string ] string )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									appliedCommandLineProperties  =  make ( [ ] string ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  section  :=  range  Cfg . Sections ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  key  :=  range  section . Keys ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											keyString  :=  fmt . Sprintf ( "default.%s.%s" ,  section . Name ( ) ,  key . Name ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											value ,  exists  :=  props [ keyString ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  exists  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												key . SetValue ( value ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-01 13:50:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  shouldRedactKey ( keyString )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-04 10:38:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													value  =  "*********" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												appliedCommandLineProperties  =  append ( appliedCommandLineProperties ,  fmt . Sprintf ( "%s=%s" ,  keyString ,  value ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-08 20:31:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  applyCommandLineProperties ( props  map [ string ] string )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  section  :=  range  Cfg . Sections ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  key  :=  range  section . Keys ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											keyString  :=  fmt . Sprintf ( "%s.%s" ,  section . Name ( ) ,  key . Name ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											value ,  exists  :=  props [ keyString ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  exists  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												key . SetValue ( value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												appliedCommandLineProperties  =  append ( appliedCommandLineProperties ,  fmt . Sprintf ( "%s=%s" ,  keyString ,  value ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-02-15 14:57:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  getCommandLineProperties ( args  [ ] string )  map [ string ] string  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									props  :=  make ( map [ string ] string ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  _ ,  arg  :=  range  args  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ! strings . HasPrefix ( arg ,  "cfg:" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										trimmed  :=  strings . TrimPrefix ( arg ,  "cfg:" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parts  :=  strings . Split ( trimmed ,  "=" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  len ( parts )  !=  2  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											log . Fatal ( 3 ,  "Invalid command line argument" ,  arg ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-05 07:59:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										props [ parts [ 0 ] ]  =  parts [ 1 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  props 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  makeAbsolute ( path  string ,  root  string )  string  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  filepath . IsAbs ( path )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  path 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  filepath . Join ( root ,  path ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  evalEnvVarExpression ( value  string )  string  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									regex  :=  regexp . MustCompile ( ` \$ { (\w+)} ` ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  regex . ReplaceAllStringFunc ( value ,  func ( envVar  string )  string  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										envVar  =  strings . TrimPrefix ( envVar ,  "${" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										envVar  =  strings . TrimSuffix ( envVar ,  "}" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										envValue  :=  os . Getenv ( envVar ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-02 14:32:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// if env variable is hostname and it is emtpy use os.Hostname as default 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  envVar  ==  "HOSTNAME"  &&  envValue  ==  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											envValue ,  _  =  os . Hostname ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  envValue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  evalConfigValues ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  section  :=  range  Cfg . Sections ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  key  :=  range  section . Keys ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											key . SetValue ( evalEnvVarExpression ( key . Value ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-01 02:37:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  loadSpecifedConfigFile ( configFile  string )  error  {  
						 
					
						
							
								
									
										
										
										
											2015-04-12 09:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  configFile  ==  ""  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-08 13:22:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										configFile  =  filepath . Join ( HomePath ,  CustomInitPath ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-12 09:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// return without error if custom file does not exist 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ! pathExists ( configFile )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-01 02:37:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-12 09:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 10:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									userConfig ,  err  :=  ini . Load ( configFile ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-01 02:37:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Failed to parse %v, %v" ,  configFile ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 10:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 17:55:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									userConfig . BlockMode  =  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 10:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  _ ,  section  :=  range  userConfig . Sections ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  key  :=  range  section . Keys ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  key . Value ( )  ==  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											defaultSec ,  err  :=  Cfg . GetSection ( section . Name ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-19 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												defaultSec ,  _  =  Cfg . NewSection ( section . Name ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 10:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											defaultKey ,  err  :=  defaultSec . GetKey ( key . Name ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-19 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												defaultKey ,  _  =  defaultSec . NewKey ( key . Name ( ) ,  key . Value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 10:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											defaultKey . SetValue ( key . Value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									configFiles  =  append ( configFiles ,  configFile ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-01 02:37:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 10:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  loadConfiguration ( args  * CommandLineArgs )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  err  error 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// load config defaults 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									defaultConfigFile  :=  path . Join ( HomePath ,  "conf/defaults.ini" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									configFiles  =  append ( configFiles ,  defaultConfigFile ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-06 07:36:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check if config file exists 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  _ ,  err  :=  os . Stat ( defaultConfigFile ) ;  os . IsNotExist ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										fmt . Println ( "Grafana-server Init Failed: Could not find config defaults, make sure homepath command line parameter is set or working directory is homepath" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										os . Exit ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// load defaults 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Cfg ,  err  =  ini . Load ( defaultConfigFile ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-06 07:36:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										fmt . Println ( fmt . Sprintf ( "Failed to parse defaults.ini, %v" ,  err ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										os . Exit ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-18 16:43:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Cfg . BlockMode  =  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// command line props 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									commandLineProps  :=  getCommandLineProperties ( args . Args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// load default overrides 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									applyCommandLineDefaultProperties ( commandLineProps ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// load specified config file 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-01 02:37:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									err  =  loadSpecifedConfigFile ( args . Config ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										initLogging ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										log . Fatal ( 3 ,  err . Error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// apply environment overrides 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									applyEnvVariableOverrides ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// apply command line overrides 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									applyCommandLineProperties ( commandLineProps ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-08 14:10:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// evaluate config values containing environment variables 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									evalConfigValues ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 10:15:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// update data path and logging config 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DataPath  =  makeAbsolute ( Cfg . Section ( "paths" ) . Key ( "data" ) . String ( ) ,  HomePath ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-06 23:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									initLogging ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-12 09:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  pathExists ( path  string )  bool  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_ ,  err  :=  os . Stat ( path ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  os . IsNotExist ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  setHomePath ( args  * CommandLineArgs )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  args . HomePath  !=  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										HomePath  =  args . HomePath 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HomePath ,  _  =  filepath . Abs ( "." ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// check if homepath is correct 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  pathExists ( filepath . Join ( HomePath ,  "conf/defaults.ini" ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// try down one path 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  pathExists ( filepath . Join ( HomePath ,  "../conf/defaults.ini" ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										HomePath  =  filepath . Join ( HomePath ,  "../" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 08:58:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  skipStaticRootValidation  bool  =  false  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  validateStaticRootPath ( )  error  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  skipStaticRootValidation  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-10 13:34:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-14 15:54:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  _ ,  err  :=  os . Stat ( path . Join ( StaticRootPath ,  "css" ) ) ;  err  ==  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-14 13:42:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  nil 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 08:58:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  _ ,  err  :=  os . Stat ( StaticRootPath  +  "_gen/css" ) ;  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										StaticRootPath  =  StaticRootPath  +  "_gen" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-10 13:34:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-19 16:00:51 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  fmt . Errorf ( "Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?" ,  StaticRootPath ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-10 13:34:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-02 14:32:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// func readInstanceName() string {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	hostname, _ := os.Hostname()  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	if hostname == "" {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 		hostname = "hostname_unknown"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	instanceName := Cfg.Section("").Key("instance_name").MustString("")  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	if instanceName = "" {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 		// set value as it might be used in other places  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 		Cfg.Section("").Key("instance_name").SetValue(hostname)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 		instanceName = hostname  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 	return  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// }  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 08:58:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  NewConfigContext ( args  * CommandLineArgs )  error  {  
						 
					
						
							
								
									
										
										
										
											2015-04-12 09:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									setHomePath ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									loadConfiguration ( args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Env  =  Cfg . Section ( "" ) . Key ( "app_mode" ) . MustString ( "development" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-02 14:32:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									InstanceName  =  Cfg . Section ( "" ) . Key ( "instance_name" ) . MustString ( "unknown_instance_name" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 15:36:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PluginsPath  =  makeAbsolute ( Cfg . Section ( "paths" ) . Key ( "plugins" ) . String ( ) ,  HomePath ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									server  :=  Cfg . Section ( "server" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AppUrl ,  AppSubUrl  =  parseAppUrlAndSubUrl ( server ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Protocol  =  HTTP 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  server . Key ( "protocol" ) . MustString ( "http" )  ==  "https"  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										Protocol  =  HTTPS 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CertFile  =  server . Key ( "cert_file" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-11 19:44:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										KeyFile  =  server . Key ( "cert_key" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-04 13:33:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Domain  =  server . Key ( "domain" ) . MustString ( "localhost" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									HttpAddr  =  server . Key ( "http_addr" ) . MustString ( DEFAULT_HTTP_ADDR ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									HttpPort  =  server . Key ( "http_port" ) . MustString ( "3000" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									RouterLogging  =  server . Key ( "router_logging" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-16 12:43:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									EnableGzip  =  server . Key ( "enable_gzip" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-05 11:21:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									EnforceDomain  =  server . Key ( "enforce_domain" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 08:58:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									StaticRootPath  =  makeAbsolute ( server . Key ( "static_root_path" ) . String ( ) ,  HomePath ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  :=  validateStaticRootPath ( ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  err 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-16 12:43:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// read data proxy settings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									dataproxy  :=  Cfg . Section ( "dataproxy" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DataProxyLogging  =  dataproxy . Key ( "logging" ) . MustBool ( false ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 17:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// read security settings 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									security  :=  Cfg . Section ( "security" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SecretKey  =  security . Key ( "secret_key" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LogInRememberDays  =  security . Key ( "login_remember_days" ) . MustInt ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CookieUserName  =  security . Key ( "cookie_username" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CookieRememberName  =  security . Key ( "cookie_remember_name" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 08:40:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DisableGravatar  =  security . Key ( "disable_gravatar" ) . MustBool ( true ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-14 17:39:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// read snapshots settings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									snapshots  :=  Cfg . Section ( "snapshots" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExternalSnapshotUrl  =  snapshots . Key ( "external_snapshot_url" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExternalSnapshotName  =  snapshots . Key ( "external_snapshot_name" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExternalEnabled  =  snapshots . Key ( "external_enabled" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-23 16:56:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SnapShotRemoveExpired  =  snapshots . Key ( "snapshot_remove_expired" ) . MustBool ( true ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SnapShotTTLDays  =  snapshots . Key ( "snapshot_TTL_days" ) . MustInt ( 90 ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-14 17:39:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 17:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									//  read data source proxy white list 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DataProxyWhiteList  =  make ( map [ string ] bool ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  hostAndIp  :=  range  security . Key ( "data_source_proxy_whitelist" ) . Strings ( " " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										DataProxyWhiteList [ hostAndIp ]  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 15:45:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// admin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AdminUser  =  security . Key ( "admin_user" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AdminPassword  =  security . Key ( "admin_password" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-11 16:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									users  :=  Cfg . Section ( "users" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AllowUserSignUp  =  users . Key ( "allow_sign_up" ) . MustBool ( true ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AllowUserOrgCreate  =  users . Key ( "allow_org_create" ) . MustBool ( true ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AutoAssignOrg  =  users . Key ( "auto_assign_org" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-05 23:04:47 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AutoAssignOrgRole  =  users . Key ( "auto_assign_org_role" ) . In ( "Editor" ,  [ ] string { "Editor" ,  "Admin" ,  "Read Only Editor" ,  "Viewer" } ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-31 11:35:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									VerifyEmailEnabled  =  users . Key ( "verify_email_enabled" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-20 11:15:36 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LoginHint  =  users . Key ( "login_hint" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-12 15:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DefaultTheme  =  users . Key ( "default_theme" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-28 15:27:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// auth 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									auth  :=  Cfg . Section ( "auth" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DisableLoginForm  =  auth . Key ( "disable_login_form" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 15:14:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 15:45:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// anonymous access 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AnonymousEnabled  =  Cfg . Section ( "auth.anonymous" ) . Key ( "enabled" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-23 20:07:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AnonymousOrgName  =  Cfg . Section ( "auth.anonymous" ) . Key ( "org_name" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AnonymousOrgRole  =  Cfg . Section ( "auth.anonymous" ) . Key ( "org_role" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-07 16:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 11:55:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// auth proxy 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									authProxy  :=  Cfg . Section ( "auth.proxy" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyEnabled  =  authProxy . Key ( "enabled" ) . MustBool ( false ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyHeaderName  =  authProxy . Key ( "header_name" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyHeaderProperty  =  authProxy . Key ( "header_property" ) . String ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyAutoSignUp  =  authProxy . Key ( "auto_sign_up" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-23 14:22:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AuthProxyLdapSyncTtl  =  authProxy . Key ( "ldap_sync_ttl" ) . MustInt ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									AuthProxyWhitelist  =  authProxy . Key ( "whitelist" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 11:55:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-23 14:22:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// basic auth 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 09:37:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									authBasic  :=  Cfg . Section ( "auth.basic" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 12:14:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									BasicAuthEnabled  =  authBasic . Key ( "enabled" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 09:37:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-06 15:31:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// PhantomJS rendering 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-08 14:10:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ImagesDir  =  filepath . Join ( DataPath ,  "png" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PhantomDir  =  filepath . Join ( HomePath ,  "vendor/phantomjs" ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-14 17:13:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-27 17:13:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									analytics  :=  Cfg . Section ( "analytics" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ReportingEnabled  =  analytics . Key ( "reporting_enabled" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-11 12:21:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CheckForUpdates  =  analytics . Key ( "check_for_updates" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-27 17:13:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GoogleAnalyticsId  =  analytics . Key ( "google_analytics_ua_id" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-21 09:30:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GoogleTagManagerId  =  analytics . Key ( "google_tag_manager_id" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-22 15:14:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-04 09:34:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ldapSec  :=  Cfg . Section ( "auth.ldap" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LdapEnabled  =  ldapSec . Key ( "enabled" ) . MustBool ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 10:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LdapConfigFile  =  ldapSec . Key ( "config_file" ) . String ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-07 01:49:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LdapAllowSignup  =  ldapSec . Key ( "allow_sign_up" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-04 09:34:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-29 14:35:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									alerting  :=  Cfg . Section ( "alerting" ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-25 13:32:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									AlertingEnabled  =  alerting . Key ( "enabled" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-10 13:09:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ExecuteAlerts  =  alerting . Key ( "execute_alerts" ) . MustBool ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-29 14:35:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-15 14:44:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									readSessionConfig ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-08 17:56:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									readSmtpSettings ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 01:47:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									readQuotaSettings ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-31 11:35:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  VerifyEmailEnabled  &&  ! Smtp . Enabled  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										log . Warn ( "require_email_validation is enabled but smpt is disabled" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 08:58:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-28 13:10:31 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GrafanaNetUrl  =  Cfg . Section ( "grafana_net" ) . Key ( "url" ) . MustString ( "https://grafana.net" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-27 13:52:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-10 17:27:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									imageUploadingSection  :=  Cfg . Section ( "external_image_storage" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ImageUploadProvider  =  imageUploadingSection . Key ( "provider" ) . MustString ( "internal" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 08:58:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-15 14:44:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-12-30 10:28:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-15 14:44:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  readSessionConfig ( )  {  
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									sec  :=  Cfg . Section ( "session" ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-30 10:28:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions  =  session . Options { } 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-08 13:35:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions . Provider  =  sec . Key ( "provider" ) . In ( "memory" ,  [ ] string { "memory" ,  "file" ,  "redis" ,  "mysql" ,  "postgres" ,  "memcache" } ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions . ProviderConfig  =  strings . Trim ( sec . Key ( "provider_config" ) . String ( ) ,  "\" " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SessionOptions . CookieName  =  sec . Key ( "cookie_name" ) . MustString ( "grafana_sess" ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-30 10:28:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions . CookiePath  =  AppSubUrl 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 10:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions . Secure  =  sec . Key ( "cookie_secure" ) . MustBool ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SessionOptions . Gclifetime  =  Cfg . Section ( "session" ) . Key ( "gc_interval_time" ) . MustInt64 ( 86400 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SessionOptions . Maxlifetime  =  Cfg . Section ( "session" ) . Key ( "session_life_time" ) . MustInt64 ( 86400 ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-07 19:21:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SessionOptions . IDLength  =  16 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-30 10:28:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  SessionOptions . Provider  ==  "file"  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										SessionOptions . ProviderConfig  =  makeAbsolute ( SessionOptions . ProviderConfig ,  DataPath ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-30 10:28:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										os . MkdirAll ( path . Dir ( SessionOptions . ProviderConfig ) ,  os . ModePerm ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-08 08:59:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  SessionOptions . CookiePath  ==  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SessionOptions . CookiePath  =  "/" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-05 16:50:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-06 23:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  initLogging ( )  {  
						 
					
						
							
								
									
										
										
										
											2016-06-07 12:11:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// split on comma 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LogModes  =  strings . Split ( Cfg . Section ( "log" ) . Key ( "mode" ) . MustString ( "console" ) ,  "," ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 12:11:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// also try space 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( LogModes )  ==  1  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										LogModes  =  strings . Split ( Cfg . Section ( "log" ) . Key ( "mode" ) . MustString ( "console" ) ,  " " ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									LogsPath  =  makeAbsolute ( Cfg . Section ( "paths" ) . Key ( "logs" ) . String ( ) ,  HomePath ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-06 23:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									log . ReadLoggingConfig ( LogModes ,  LogsPath ,  Cfg ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  LogConfigurationInfo ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  text  bytes . Buffer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 09:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  _ ,  file  :=  range  configFiles  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										logger . Info ( "Config loaded from" ,  "file" ,  file ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( appliedCommandLineProperties )  >  0  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 09:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										for  _ ,  prop  :=  range  appliedCommandLineProperties  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											logger . Info ( "Config overriden from command line" ,  "arg" ,  prop ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  len ( appliedEnvOverrides )  >  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										text . WriteString ( "\tEnvironment variables used:\n" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 09:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										for  _ ,  prop  :=  range  appliedEnvOverrides  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											logger . Info ( "Config overriden from Environment variable" ,  "var" ,  prop ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-09 12:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-07 09:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . Info ( "Path Home" ,  "path" ,  HomePath ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									logger . Info ( "Path Data" ,  "path" ,  DataPath ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									logger . Info ( "Path Logs" ,  "path" ,  LogsPath ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									logger . Info ( "Path Plugins" ,  "path" ,  PluginsPath ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-03 10:18:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}