mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 06:19:20 +08:00
refactor: support modified config and args in mage. (#3466)
* refactor: support modified config and args in mage. * fix: update go make version.
This commit is contained in:
+66
-3
@@ -12,15 +12,48 @@ import (
|
||||
|
||||
var Default = Build
|
||||
|
||||
var Aliases = map[string]any{
|
||||
"buildcc": BuildWithCustomConfig,
|
||||
"startcc": StartWithCustomConfig,
|
||||
}
|
||||
|
||||
var (
|
||||
customRootDir = "." // workDir in mage, default is "./"(project root directory)
|
||||
customSrcDir = "cmd" // source code directory, default is "cmd"
|
||||
customOutputDir = "_output" // output directory, default is "_output"
|
||||
customConfigDir = "config" // configuration directory, default is "config"
|
||||
customToolsDir = "tools" // tools source code directory, default is "tools"
|
||||
)
|
||||
|
||||
|
||||
// Build support specifical binary build.
|
||||
//
|
||||
// Example: `mage build openim-api openim-rpc-user seq`
|
||||
func Build() {
|
||||
flag.Parse()
|
||||
|
||||
bin := flag.Args()
|
||||
if len(bin) != 0 {
|
||||
bin = bin[1:]
|
||||
}
|
||||
|
||||
mageutil.Build(bin)
|
||||
mageutil.Build(bin, nil)
|
||||
}
|
||||
|
||||
func BuildWithCustomConfig() {
|
||||
flag.Parse()
|
||||
bin := flag.Args()
|
||||
if len(bin) != 0 {
|
||||
bin = bin[1:]
|
||||
}
|
||||
|
||||
config := &mageutil.PathOptions{
|
||||
RootDir: &customRootDir,
|
||||
OutputDir: &customOutputDir,
|
||||
SrcDir: &customSrcDir,
|
||||
ToolsDir: &customToolsDir,
|
||||
}
|
||||
|
||||
mageutil.Build(bin, config)
|
||||
}
|
||||
|
||||
func Start() {
|
||||
@@ -30,7 +63,37 @@ func Start() {
|
||||
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
mageutil.StartToolsAndServices()
|
||||
|
||||
flag.Parse()
|
||||
bin := flag.Args()
|
||||
if len(bin) != 0 {
|
||||
bin = bin[1:]
|
||||
}
|
||||
|
||||
mageutil.StartToolsAndServices(bin, nil)
|
||||
}
|
||||
|
||||
func StartWithCustomConfig() {
|
||||
mageutil.InitForSSC()
|
||||
err := setMaxOpenFiles()
|
||||
if err != nil {
|
||||
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
bin := flag.Args()
|
||||
if len(bin) != 0 {
|
||||
bin = bin[1:]
|
||||
}
|
||||
|
||||
config := &mageutil.PathOptions{
|
||||
RootDir: &customRootDir,
|
||||
OutputDir: &customOutputDir,
|
||||
ConfigDir: &customConfigDir,
|
||||
}
|
||||
|
||||
mageutil.StartToolsAndServices(bin, config)
|
||||
}
|
||||
|
||||
func Stop() {
|
||||
|
||||
Reference in New Issue
Block a user