Merge pull request #539 from trheyi/main

[fea] runtime performance mode support
This commit is contained in:
Max 2023-12-28 21:29:05 +08:00 committed by GitHub
commit bf78a949dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View file

@ -41,6 +41,9 @@ var runCmd = &cobra.Command{
Boot()
// Set Runtime Mode
config.Conf.Runtime.Mode = "standard"
cfg := config.Conf
cfg.Session.IsCLI = true
if len(args) < 1 {

View file

@ -89,10 +89,15 @@ var startCmd = &cobra.Command{
mode := config.Conf.Mode
host := config.Conf.Host
dataRoot := fs.Root()
runtimeMode := config.Conf.Runtime.Mode
fmt.Println(color.WhiteString("\n---------------------------------"))
fmt.Println(color.WhiteString(strings.TrimPrefix(share.App.Name, "::")), color.WhiteString(share.App.Version), mode)
fmt.Println(color.WhiteString("---------------------------------"))
fmt.Println(color.WhiteString("\n--------------------------------------------"))
fmt.Println(
color.WhiteString(strings.TrimPrefix(share.App.Name, "::")),
color.WhiteString(share.App.Version),
mode,
)
fmt.Println(color.WhiteString("--------------------------------------------"))
if !share.BUILDIN {
root, _ := filepath.Abs(config.Conf.Root)
fmt.Println(color.WhiteString(L("Root")), color.GreenString(" %s", root))
@ -104,6 +109,7 @@ var startCmd = &cobra.Command{
urls, _ = setup.URLs(config.Conf)
}
fmt.Println(color.WhiteString(L("Runtime")), color.GreenString(" %s", runtimeMode))
fmt.Println(color.WhiteString(L("Data")), color.GreenString(" %s", dataRoot))
fmt.Println(color.WhiteString(L("Listening")), color.GreenString(" %s:%d", config.Conf.Host, config.Conf.Port))
for _, url := range urls {

View file

@ -53,8 +53,8 @@ type Session struct {
// Runtime Config
type Runtime struct {
Mode string `json:"mode,omitempty" env:"YAO_RUNTIME_MODE" envDefault:"standard"` // the mode of the runtime, the default value is "standard" and the other value is "performance". "performance" mode need more memory but will run faster
MinSize int `json:"minSize,omitempty" env:"YAO_RUNTIME_MIN" envDefault:"10"` // the number of V8 VM when runtime start. max value is 100, the default value is 2
MaxSize int `json:"maxSize,omitempty" env:"YAO_RUNTIME_MAX" envDefault:"100"` // the maximum of V8 VM should be smaller than minSize, the default value is 10
MinSize uint `json:"minSize,omitempty" env:"YAO_RUNTIME_MIN" envDefault:"10"` // the number of V8 VM when runtime start. max value is 100, the default value is 2
MaxSize uint `json:"maxSize,omitempty" env:"YAO_RUNTIME_MAX" envDefault:"100"` // the maximum of V8 VM should be smaller than minSize, the default value is 10
DefaultTimeout int `json:"defaultTimeout,omitempty" env:"YAO_RUNTIME_TIMEOUT" envDefault:"200"` // the default timeout for the script, the default value is 200ms
ContextTimeout int `json:"contextTimeout,omitempty" env:"YAO_RUNTIME_CONTEXT_TIMEOUT" envDefault:"200"` // the default timeout for the context, the default value is 200ms
HeapSizeLimit uint64 `json:"heapSizeLimit,omitempty" env:"YAO_RUNTIME_HEAP_LIMIT" envDefault:"1518338048"` // the isolate heap size limit should be smaller than 1.5G, and the default value is 1518338048 (1.5G)