广告平台(站长使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init_rabbitmq.go 687 B

4 months ago
12345678910111213141516171819202122232425262728
  1. package cfg
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
  4. "encoding/json"
  5. "os"
  6. "strings"
  7. "time"
  8. )
  9. func InitMq() {
  10. data, _ := json.Marshal(MQ)
  11. filePutContents("init_rabbit_mq", string(data))
  12. err := rabbit.Init(MQ.Host, MQ.Port, MQ.User, MQ.Pwd)
  13. if err != nil {
  14. filePutContents("init_rabbit_mq", err.Error())
  15. return
  16. }
  17. }
  18. func filePutContents(fileName string, content string) {
  19. fd, _ := os.OpenFile("./tmp/"+fileName+".log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
  20. fd_time := time.Now().Format("2006-01-02 15:04:05")
  21. fd_content := strings.Join([]string{"[", fd_time, "] ", content, "\n"}, "")
  22. buf := []byte(fd_content)
  23. fd.Write(buf)
  24. fd.Close()
  25. }