Commit bbbc3800 authored by Eric_Lee's avatar Eric_Lee Committed by Eric

fix docker config from env (#77)

parent a125e737
...@@ -7,13 +7,5 @@ do ...@@ -7,13 +7,5 @@ do
sleep 2 sleep 2
done done
if [ ! -f "/opt/coco/config.yml" ]; then
cp /opt/coco/config_example.yml /opt/coco/config.yml
sed -i '5d' /opt/coco/config.yml
sed -i "5i CORE_HOST: $CORE_HOST" /opt/coco/config.yml
sed -i "s/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml
sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml
fi
cd /opt/coco cd /opt/coco
./koko ./koko
...@@ -71,6 +71,7 @@ func (c *Config) LoadFromYAMLPath(filepath string) error { ...@@ -71,6 +71,7 @@ func (c *Config) LoadFromYAMLPath(filepath string) error {
body, err := ioutil.ReadFile(filepath) body, err := ioutil.ReadFile(filepath)
if err != nil { if err != nil {
log.Printf("Not found file: %s", filepath) log.Printf("Not found file: %s", filepath)
return err
} }
return c.LoadFromYAML(body) return c.LoadFromYAML(body)
} }
...@@ -100,12 +101,11 @@ func (c *Config) LoadFromEnv() error { ...@@ -100,12 +101,11 @@ func (c *Config) LoadFromEnv() error {
} }
func (c *Config) Load(filepath string) error { func (c *Config) Load(filepath string) error {
err := c.LoadFromYAMLPath(filepath) if err := c.LoadFromYAMLPath(filepath); err == nil{
if err != nil {
return err return err
} }
err = c.LoadFromEnv() log.Print("Load from env")
return err return c.LoadFromEnv()
} }
var lock = new(sync.RWMutex) var lock = new(sync.RWMutex)
......
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