From 77443534e2f4fde033bb4f3f4ca57e2b69e7b9a2 Mon Sep 17 00:00:00 2001 From: stremovsky Date: Thu, 23 Dec 2021 15:10:07 +0200 Subject: [PATCH] fix spaces, try to open db several times, add ADMIN_EMAIL env value --- src/bunker.go | 54 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/bunker.go b/src/bunker.go index 8dcd3e6..79311ef 100644 --- a/src/bunker.go +++ b/src/bunker.go @@ -40,13 +40,13 @@ type dbcon struct { // Config is u sed to store application configuration type Config struct { Generic struct { - CreateUserWithoutAccessToken bool `yaml:"create_user_without_access_token" default:false` - UseSeparateAppTables bool `yaml:"use_separate_app_tables" default:false` - UserRecordSchema string `yaml:"user_record_schema"` - AdminEmail string `yaml:"admin_email"` + CreateUserWithoutAccessToken bool `yaml:"create_user_without_access_token" default:false` + UseSeparateAppTables bool `yaml:"use_separate_app_tables" default:false` + UserRecordSchema string `yaml:"user_record_schema"` + AdminEmail string `yaml:"admin_email" envconfig:"ADMIN_EMAIL"` } SelfService struct { - ForgetMe bool `yaml:"forget_me" default:false` + ForgetMe bool `yaml:"forget_me" default:false` UserRecordChange bool `yaml:"user_record_change" default:false` AppRecordChange []string `yaml:"app_record_change"` } @@ -56,9 +56,9 @@ type Config struct { MagicSyncToken string `yaml:"magic_sync_token"` } Policy struct { - MaxUserRetentionPeriod string `yaml:"max_user_retention_period" default:"1m"` - MaxAuditRetentionPeriod string `yaml:"max_audit_retention_period" default:"12m"` - MaxSessionRetentionPeriod string `yaml:"max_session_retention_period" default:"1h"` + MaxUserRetentionPeriod string `yaml:"max_user_retention_period" default:"1m"` + MaxAuditRetentionPeriod string `yaml:"max_audit_retention_period" default:"12m"` + MaxSessionRetentionPeriod string `yaml:"max_session_retention_period" default:"1h"` MaxShareableRecordRetentionPeriod string `yaml:"max_shareable_record_retention_period" default:"1m"` } Ssl struct { @@ -66,15 +66,15 @@ type Config struct { SslCertificateKey string `yaml:"ssl_certificate_key" envconfig:"SSL_CERTIFICATE_KEY"` } Sms struct { - Url string `yaml:"url"` - From string `yaml:"from"` - Body string `yaml:"body"` - Token string `yaml:"token"` - Method string `yaml:"method"` - BasicAuth string `yaml:"basic_auth"` - ContentType string `yaml:"content_type"` - CustomHeader string `yaml:"custom_header"` - DefaultCountry string `yaml:"default_country"` + Url string `yaml:"url"` + From string `yaml:"from"` + Body string `yaml:"body"` + Token string `yaml:"token"` + Method string `yaml:"method"` + BasicAuth string `yaml:"basic_auth"` + ContentType string `yaml:"content_type"` + CustomHeader string `yaml:"custom_header"` + DefaultCountry string `yaml:"default_country"` } Server struct { Port string `yaml:"port" envconfig:"BUNKER_PORT"` @@ -88,11 +88,11 @@ type Config struct { Sender string `yaml:"sender" envconfig:"SMTP_SENDER"` } `yaml:"smtp"` UI struct { - LogoLink string `yaml:"logo_link"` - CompanyTitle string `yaml:"company_title"` - CompanyVAT string `yaml:"company_vat"` - CompanyCity string `yaml:"company_city"` - CompanyLink string `yaml:"company_link"` + LogoLink string `yaml:"logo_link"` + CompanyTitle string `yaml:"company_title"` + CompanyVAT string `yaml:"company_vat"` + CompanyCity string `yaml:"company_city"` + CompanyLink string `yaml:"company_link"` CompanyCountry string `yaml:"company_country"` CompanyAddress string `yaml:"company_address"` TermOfServiceTitle string `yaml:"term_of_service_title"` @@ -100,7 +100,7 @@ type Config struct { PrivacyPolicyTitle string `yaml:"privacy_policy_title"` PrivacyPolicyLink string `yaml:"privacy_policy_link"` CustomCSSLink string `yaml:"custom_css_link"` - MagicLookup bool `yaml:"magic_lookup"` + MagicLookup bool `yaml:"magic_lookup"` } `yaml:"ui"` } @@ -547,7 +547,13 @@ func main() { } os.Exit(0) } - if storage.DBExists(dbPtr) == false { + db_flag := storage.DBExists(dbPtr) + for num_attempts := 60; db_flag == false && num_attempts > 0; num_attempts-- { + time.Sleep(1 * time.Second) + fmt.Printf("Trying to open db: %d\n", 61-num_attempts) + db_flag = storage.DBExists(dbPtr) + } + if db_flag == false { fmt.Printf("\nDatabase is not initialized.\n\n") fmt.Println(`Run "databunker -init" for the first time to generate keys and init database.`) fmt.Println("")