2022-11-03 20:09:04 +08:00
|
|
|
package install
|
|
|
|
|
|
|
|
import (
|
2022-11-08 18:28:15 +08:00
|
|
|
"fmt"
|
2022-11-03 20:09:04 +08:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/answerdev/answer/internal/base/translator"
|
|
|
|
"github.com/answerdev/answer/internal/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
port = os.Getenv("INSTALL_PORT")
|
|
|
|
confPath = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
func Run(configPath string) {
|
|
|
|
confPath = configPath
|
|
|
|
// initialize translator for return internationalization error when installing.
|
|
|
|
_, err := translator.NewTranslator(&translator.I18n{BundleDir: cli.I18nPath})
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
installServer := NewInstallHTTPServer()
|
|
|
|
if len(port) == 0 {
|
|
|
|
port = "80"
|
|
|
|
}
|
2022-11-08 18:28:15 +08:00
|
|
|
fmt.Printf("[SUCCESS] answer installation service will run at: http://localhost:%s/install/ \n", port)
|
2022-11-03 20:09:04 +08:00
|
|
|
if err = installServer.Run(":" + port); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|