Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:the file append experiment is unreasonable #148

Merged
merged 2 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions exec/file/file_append.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewFileAppendActionSpec() spec.ExpActionCommandSpec {
},
&spec.ExpFlag{
Name: "interval",
Desc: "append interval, must be a positive integer, default 1s",
Desc: "append interval, must be a positive integer",
},
&spec.ExpFlag{
Name: "escape",
Expand Down Expand Up @@ -137,8 +137,8 @@ func (f *FileAppendActionExecutor) Exec(uid string, ctx context.Context, model *

// default 1
count := 1
// 1000 ms
interval := 1
// default 0
interval := 0

content := model.ActionFlags["content"]
countStr := model.ActionFlags["count"]
Expand Down Expand Up @@ -172,7 +172,10 @@ func (f *FileAppendActionExecutor) start(filepath string, content string, count
if !response.Success {
return response
}

// Without interval, it will not be executed regularly.
if interval < 1 {
return nil
}
ticker := time.NewTicker(time.Second * time.Duration(interval))
for range ticker.C {
response := appendFile(f.channel, count, ctx, content, filepath, escape, enableBase64)
Expand Down
3 changes: 1 addition & 2 deletions exec/systemd/systemd_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ func (sse *StopSystemdExecutor) Exec(uid string, ctx context.Context, model *spe
return spec.ResponseFailWithFlags(spec.ParameterLess, "service")
}

flags := fmt.Sprintf("--service %s", service)
if _, ok := spec.IsDestroy(ctx); ok {
return sse.startService(service, ctx)
} else {
if response := checkServiceInvalid(uid, service, ctx, sse.channel); response != nil {
return response
}
return sse.channel.Run(ctx, path.Join(sse.channel.GetScriptPath(), StopSystemdBin), flags)
return sse.channel.Run(ctx, "systemctl", fmt.Sprintf("stop %s", service))
}
}

Expand Down