Commit 435c0e43 authored by Stephan Handuwala's avatar Stephan Handuwala 🏋🏻

Merge branch 'master' into 'master'

remove panic and STD output

See merge request !11
parents 202eb0f5 d5461c49
couchdb:
port: '84'
port: '5984'
host: couchdb_emanger
username: root
password: root
curl:
check_mail: http://root:root@couchdb_emanger:84/outbox/_all_docs/?limit=1 #http://root:root@0.0.0.0:5984/outbox/_all_docs/?limit=1
get_outbox_mail: http://root:root@couchdb_emanger:84/outbox/
delete_outbox_mail: http://root:root@couchdb_emanger:84/outbox/
add_sent_mail: http://root:root@couchdb_emanger:84/sentitems/
add_mail_log: http://root:root@couchdb_emanger:84/mail_logs/
check_mail: http://root:root@couchdb_emanger:5984/outbox/_all_docs/?limit=1 #http://root:root@0.0.0.0:5984/outbox/_all_docs/?limit=1
get_outbox_mail: http://root:root@couchdb_emanger:5984/outbox/
delete_outbox_mail: http://root:root@couchdb_emanger:5984/outbox/
add_sent_mail: http://root:root@couchdb_emanger:5984/sentitems/
add_mail_log: http://root:root@couchdb_emanger:5984/mail_logs/
protocols:
method: http://
requests:
......
......@@ -154,7 +154,8 @@ func main() {
if reqErr != nil {
alert := " Error creating request to OUTBOX DB \n" + reqErr.Error()
alertAdmin(alert)
panic(reqErr)
fmt.Printf("Error : %s", reqErr.Error())
//panic(reqErr)
}
req.Header.Set(config.Requests.HeaderType, config.Requests.HeaderJson)
......@@ -162,7 +163,8 @@ func main() {
if respErr != nil {
alert := " Error in getting email from the OUTBOX DB \n" + respErr.Error()
alertAdmin(alert)
panic(respErr)
fmt.Printf("Error : %s", reqErr.Error())
//panic(respErr)
}
defer resp.Body.Close()
respbody, _ := ioutil.ReadAll(resp.Body)
......@@ -277,11 +279,13 @@ func worker(i int) {
var config Config
source, sourceErr := ioutil.ReadFile("config.yaml")
if sourceErr != nil {
panic(sourceErr)
fmt.Printf("sourceErr : %s", sourceErr.Error())
//panic(sourceErr)
}
configErr := yaml.Unmarshal(source, &config)
if configErr != nil {
panic(configErr)
fmt.Printf("configErr : %s", configErr.Error())
//panic(configErr)
}
//fmt.Println("Worker ", i, " strats working")
......@@ -352,7 +356,8 @@ func worker(i int) {
//if(attachErr != nil)
//attchResp, err := http.DefaultClient.Do(attachReq)
if err != nil {
panic(err)
fmt.Printf("attchResp : %s", err.Error())
// panic(err)
}
defer attchResp.Body.Close()
respbody, _ := ioutil.ReadAll(attchResp.Body)
......@@ -362,20 +367,24 @@ func worker(i int) {
dec, err := base64.StdEncoding.DecodeString(resp)
if err != nil {
panic(err)
fmt.Printf("Decode err : %s", err.Error())
//panic(err)
}
f, err := os.Create(filename)
if err != nil {
panic(err)
fmt.Printf("File err : %s", err.Error())
//panic(err)
}
//defer f.Close()
if _, err := f.Write(dec); err != nil {
panic(err)
fmt.Printf("File write err : %s", err.Error())
// panic(err)
}
if err := f.Sync(); err != nil {
panic(err)
fmt.Printf("Sync err : %s", err.Error())
//panic(err)
}
//message.AddHeader("Content-Type", "multipart/form-data")
......@@ -390,6 +399,7 @@ func worker(i int) {
MailgunResp, id, err := mg.Send(ctx, message)
if err != nil {
// log.Fatal(err)
fmt.Printf("MailgunResp err : %s", err.Error())
alertAdmin(" MAilgun Error \n" + err.Error())
}
if len(filename) > 0 {
......@@ -447,6 +457,7 @@ func sendMessage(mg mailgun.Mailgun, sender, subject, body, recipient, cc string
resp, id, err := mg.Send(ctx, message)
if err != nil {
//log.Fatal(err)
fmt.Printf("MAilgun Error : %s", err.Error())
alertAdmin(" MAilgun Error \n" + err.Error())
}
//fmt.Println(resp)
......@@ -454,11 +465,13 @@ func sendMessage(mg mailgun.Mailgun, sender, subject, body, recipient, cc string
var config Config
source, sourceErr := ioutil.ReadFile("config.yaml")
if sourceErr != nil {
panic(sourceErr)
fmt.Printf("Mail config err : %s", sourceErr.Error())
// panic(sourceErr)
}
configErr := yaml.Unmarshal(source, &config)
if configErr != nil {
panic(configErr)
fmt.Printf("configErr : %s", configErr.Error())
// panic(configErr)
}
if config.AppMod.Production == "0" {
......@@ -475,11 +488,13 @@ func alertAdmin(err string) {
var config Config
source, sourceErr := ioutil.ReadFile("config.yaml")
if sourceErr != nil {
panic(sourceErr)
fmt.Printf("Admin Alert err : %s", sourceErr.Error())
// panic(sourceErr)
}
configErr := yaml.Unmarshal(source, &config)
if configErr != nil {
panic(configErr)
fmt.Printf("Unmarshal err : %s", configErr.Error())
// panic(configErr)
}
// sending mail via Mailgun
......@@ -499,11 +514,13 @@ func logmail(subject, sender, recipient, cc, bcc, attachment, readTimeOutbox, ma
var config Config
source, sourceErr := ioutil.ReadFile("config.yaml")
if sourceErr != nil {
panic(sourceErr)
fmt.Printf("Logmail sourceErr : %s", sourceErr.Error())
// panic(sourceErr)
}
configErr := yaml.Unmarshal(source, &config)
if configErr != nil {
panic(configErr)
fmt.Printf("Unmarshal configErr : %s", configErr.Error())
// panic(configErr)
}
logBody := strings.NewReader(`{"Mail Subject":"` + subject +
......@@ -539,11 +556,13 @@ func sentmail(subject, sender, recipient, cc, bcc, attachment, body, mailID stri
var config Config
source, sourceErr := ioutil.ReadFile("config.yaml")
if sourceErr != nil {
panic(sourceErr)
fmt.Printf("Sentmail sourceErr : %s", sourceErr.Error())
// panic(sourceErr)
}
configErr := yaml.Unmarshal(source, &config)
if configErr != nil {
panic(configErr)
fmt.Printf("Sentmail configErr : %s", configErr.Error())
// panic(configErr)
}
sentBody := strings.NewReader(`{"Mail Subject":"` + subject +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment