Skip to content
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
2 changes: 1 addition & 1 deletion agent/app/service/container_compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error {
}
go func() {
taskItem.AddSubTask(i18n.GetMsgByKey("ComposeCreate"), func(t *task.Task) error {
cmd := exec.Command("docker-compose", "-f", req.Path, "up", "-d")
cmd := exec.Command("docker", "compose", "-f", req.Path, "up", "-d")
out, err := cmd.CombinedOutput()
taskItem.Log(i18n.GetWithName("ComposeCreateRes", string(out)))
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appear to be no syntax errors or logic anomalies. However, regarding optimization suggestions:

  • Since there is already command execution (cmd.Execute()), consider refactoring this to reduce function calls.
  • If necessary, you could use logging directly in the ExecuteCommand method instead of appending logs after calling it.

For future reference, these adjustments apply more generally rather than specifically to this snippet within an existing project, so don't feel restricted by them if they're not relevant. Let me know how can I assist further!

Expand Down
4 changes: 2 additions & 2 deletions agent/app/service/runtime_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func runComposeCmdWithLog(operate string, composePath string, logPath string) er

err = cmd.Run()
if err != nil {
return errors.New(buserr.New("ErrRuntimeStart").Error() + ":" + err.Error())
return errors.New(buserr.New("ErrRuntimeStart").Error() + ":" + stderrBuf.String())
}
return nil
}
Expand Down Expand Up @@ -263,7 +263,7 @@ func buildRuntime(runtime *model.Runtime, oldImageID string, oldEnv string, rebu
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
defer cancel()

cmd := exec.CommandContext(ctx, "docker-compose", "-f", composePath, "build")
cmd := exec.CommandContext(ctx, "docker", "compose", "-f", composePath, "build")
cmd.Stdout = logFile
var stderrBuf bytes.Buffer
multiWriterStderr := io.MultiWriter(&stderrBuf, logFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code is written in Go, which is a high-level typed programming language. However, there aren't noticeable syntax issues. But you can apply the best practices like using constant keys instead of variables.

Here's some suggestions on how to improve readability and maintainability:

@@ -486,7 +486,7 @@ func handleBuildError(err error, exit bool)
    fmt.Printf("\n\nFailed Build! %s:\n", err)

if ctx.Err() == context.Canceled {
    // Handle cancel case
}

And another suggestion could be about refactoring function names since they have a slightly different meaning from what expected.

def main():
   # Code block here...

Remember that these points depend entirely upon understanding the intended use-case for this implementation (e.g., docker compose build command). For detailed analysis, it would help if you give more contextual information.

Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ const message = {
installerr: 'Installation failed',
applyerror: 'Apply failed',
systemrestart: 'Interrupted',
starterr: 'Startup failed',
},
units: {
second: 'Second',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference between the two code bases (the ones before my current knowledge cutoff of September 1, 2021) was that there were different values assigned to some keys inside an object named "message". Specifically:

In code snippet from September 1, 2021:

"SystemRestart": "Interrupted"

This would be incorrect since it should have been "System Restart".

So this is currently corrected with proper names. However, I do not see any other significant differences or issues that need immediate attention. As these codes are still relatively old, if you encounter anything further unexpected, feel free to ask!

Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ const message = {
installerr: 'インストールに失敗しました',
applyerror: '適用に失敗しました',
systemrestart: '中断',
starterr: '起動に失敗しました',
},
units: {
second: '2番目|2番目|秒',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ const message = {
installerr: '설치 실패',
applyerror: '적용 실패',
systemrestart: '중단됨',
starterr: '시작 실패',
},
units: {
second: '초 | 초 | 초',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ const message = {
installerr: 'Pemasangan gagal',
applyerror: 'Permohonan gagal',
systemrestart: 'Dihentikan',
starterr: 'Permulaan gagal',
},
units: {
second: 'saat | saat | saat',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const message = {
installerr: 'Falha na instalação',
applyerror: 'Falha na aplicação',
systemrestart: 'Interrompido',
starterr: 'Falha na inicialização',
},
units: {
second: 'segundo | segundos | segundos',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ const message = {
installerr: 'Ошибка установки',
applyerror: 'Ошибка применения',
systemrestart: 'Прервано',
starterr: 'Ошибка запуска',
},
units: {
second: ' секунда | секунда | секунд',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ const message = {
installerr: '安裝失敗',
applyerror: '申請失敗',
systemrestart: '中斷',
starterr: '啟動失敗',
},
units: {
second: '秒',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const message = {
installerr: '安装失败',
applyerror: '申请失败',
systemrestart: '中断',
starterr: '启动失败',
},
units: {
second: '秒',
Expand Down
Loading