fix: issues
This commit is contained in:
@@ -2,8 +2,8 @@ phone: "+17622696330"
|
|||||||
app_id: 29433191
|
app_id: 29433191
|
||||||
app_hash: bc7a2f7b8893889ffa6115f5f0eac278
|
app_hash: bc7a2f7b8893889ffa6115f5f0eac278
|
||||||
bot_token:
|
bot_token:
|
||||||
session_file: ./session.json
|
session_file: ~/.cache/exporter/session.json
|
||||||
log_file: ./log.json
|
log_file: /var/log/exporter/log.json
|
||||||
output: /share/telegram/outputs
|
output: /share/telegram/outputs
|
||||||
max_size: 100MB
|
max_size: 100MB
|
||||||
dsn: "postgresql://postgres:xixi0202@10.1.1.3:5432/telegram_resource?sslmode=disable"
|
dsn: "postgresql://postgres:xixi0202@10.1.1.3:5432/telegram_resource?sslmode=disable"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
@@ -28,6 +30,10 @@ func (c *Config) GetMaxSize() uint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Load(path string) error {
|
func Load(path string) error {
|
||||||
|
path, err := filepath.Abs(path)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to get the absolute path of the config file %s", path)
|
||||||
|
}
|
||||||
// Load the config file
|
// Load the config file
|
||||||
viper.SetConfigFile(path)
|
viper.SetConfigFile(path)
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -34,7 +34,7 @@ func main() {
|
|||||||
return internal.Close()
|
return internal.Close()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "C", "config.yml", "config file")
|
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "C", "/root/.exporter.yml", "config file")
|
||||||
|
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
internal.LoginCmd(),
|
internal.LoginCmd(),
|
||||||
|
|||||||
Reference in New Issue
Block a user