Skip to content

How to Resolve the 'Failed to Connect to Database' Error

ByoungSeob Kim edited this page Jan 24, 2024 · 2 revisions
  • 상황
    • 기존 설치된 Go 개발 환경에서 CB-Spider 서버 가동시(start.sh 실행) 다음과 같은 오류를 만났을 때

      ```
      panic: Failed to Connect to Database
      goroutine 1 [running]:
      [github.com/cloud-barista/cb-spider/cloud-info-manager/connection-config-info-manager.init.0()](http://github.com/cloud-barista/cb-spider/cloud-info-manager/connection-config-info-manager.init.0())
              /home/ubuntu/workspace/cb-spider-master/cloud-info-manager/connection-config-info-manager/ConnectionConfigInfoManager.go:41 +0xde
      ```
      

  • 원인
    • Spider가 활용하는 Gorm은 Go build 시 CGO On 필요

  • 설정
     * 확인
     $ go env |grep CGO_ENABLED
     CGO_ENABLED='0'
    
     * On 설정
     $ go env -w CGO_ENABLED=1
    
     * 확인
     $ go env |grep CGO_ENABLED
     CGO_ENABLED='1'
    

  • CB-Spider rebuild 필요

Table of contents



Clone this wiki locally