Skip to content

Commit

Permalink
fix: worker running into memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Sep 21, 2023
1 parent 5048beb commit af05d59
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/project/project_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package project

import (
"context"
"github.com/FriendsOfShopware/shopware-cli/shop"
"fmt"
"os"
"os/exec"
"os/signal"
Expand All @@ -11,6 +11,8 @@ import (
"sync"
"syscall"

"github.com/FriendsOfShopware/shopware-cli/shop"

"github.com/spf13/cobra"

"github.com/FriendsOfShopware/shopware-cli/logging"
Expand All @@ -26,6 +28,7 @@ var projectWorkerCmd = &cobra.Command{

isVerbose, _ := cobraCmd.Flags().GetBool("verbose")
queuesToConsume, _ := cobraCmd.Flags().GetString("queue")
memoryLimit, _ := cobraCmd.Flags().GetString("memory-limit")

if projectRoot, err = findClosestShopwareProject(); err != nil {
return err
Expand All @@ -39,10 +42,14 @@ var projectWorkerCmd = &cobra.Command{
}
}

if memoryLimit == "" {
memoryLimit = "512M"
}

cancelCtx, cancel := context.WithCancel(cobraCmd.Context())
cancelOnTermination(cancelCtx, cancel)

consumeArgs := []string{"bin/console", "messenger:consume"}
consumeArgs := []string{"bin/console", "messenger:consume", fmt.Sprintf("--memory-limit=%s", memoryLimit)}

if queuesToConsume == "" {
if is, _ := shop.IsShopwareVersion(projectRoot, ">=6.5"); is {
Expand Down Expand Up @@ -83,6 +90,7 @@ func init() {
projectRootCmd.AddCommand(projectWorkerCmd)
projectWorkerCmd.PersistentFlags().Bool("verbose", false, "Enable verbose output")
projectWorkerCmd.PersistentFlags().String("queue", "", "Queues to consume")
projectWorkerCmd.PersistentFlags().String("memory-limit", "", "Memory Limit")
}

func cancelOnTermination(ctx context.Context, cancel context.CancelFunc) {
Expand Down

0 comments on commit af05d59

Please sign in to comment.