功能修改
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
companion "browser.local/plugins/scum-server-plugin/companion"
|
||||
)
|
||||
|
||||
func main() {
|
||||
result := companion.SmokeResult{CompletedCommandIDs: []string{}, UnsupportedCommandIDs: []string{}}
|
||||
if len(os.Args) != 1 {
|
||||
writeResult(result)
|
||||
os.Exit(1)
|
||||
}
|
||||
file, err := os.Open("config.yaml")
|
||||
if err != nil {
|
||||
writeResult(result)
|
||||
os.Exit(1)
|
||||
}
|
||||
config, err := companion.LoadConfig(file)
|
||||
closeErr := file.Close()
|
||||
if err != nil || closeErr != nil {
|
||||
writeResult(result)
|
||||
os.Exit(1)
|
||||
}
|
||||
client, err := companion.NewClient(config, companion.Options{})
|
||||
if err != nil {
|
||||
writeResult(result)
|
||||
os.Exit(1)
|
||||
}
|
||||
_ = os.Unsetenv(companion.ProofEnvironment)
|
||||
isolated := os.Getenv(companion.SmokeIsolationEnvironment) == companion.SmokeIsolationValue
|
||||
requestBudget := time.Duration(config.Timing.RequestTimeoutSeconds) * time.Second * time.Duration(2*companion.SmokeClaimLimit+4)
|
||||
if requestBudget > 45*time.Second {
|
||||
requestBudget = 45 * time.Second
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), requestBudget)
|
||||
defer cancel()
|
||||
result, err = companion.RunOneShotSmoke(ctx, client, companion.SmokeOptions{IsolatedNonProduction: isolated})
|
||||
writeResult(result)
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func writeResult(result companion.SmokeResult) {
|
||||
_ = json.NewEncoder(os.Stdout).Encode(result)
|
||||
}
|
||||
Reference in New Issue
Block a user