Skip to content

dapr stop does not kill additional processes spun up by an app process #1184

@mukundansundar

Description

@mukundansundar

Version

This is with latest master build of CLI

Expected Behavior

When an application is run in golang using the go run command, and it is started using dapr run -f, it is expected that dapr stop -f will properly interrupt and kill the go run process and associated app process.

Actual Behavior

dapr stop -f stops the go run process, but another process thats started by go run still keeps running
eg: /var/folders/8n/vhq7f8w1419g3t4ww_46_tlr0000gn/T/go-build2324290313/b001/exe/app

Steps to Reproduce the Problem

When the distributed calc application in quickstarts is run using the new dapr run -f template

version: 1
apps:
  - appDirPath: ./go/
    appID: addapp
    appPort: 6000
    daprHTTPPort: 3503
    command: ["go", "run", "app.go"]
  - appID: divideapp
    appDirPath: ./node/
    appPort: 4000
    daprHTTPPort: 3502
    command: ["node", "app.js"]
  - appID: multiplyapp
    appDirPath: ./python/
    appPort: 5001
    daprHTTPPort: 3501
    command: ["flask", "run"]
    env:
      FLASK_RUN_PORT: 5001
  - appID: subtractapp
    appDirPath: ./csharp/
    appPort: 7001
    daprHTTPPort: 3504
    env:
      ASPNETCORE_URLS: 'http://localhost:7001'
    command: ["dotnet", "./bin/Debug/netcoreapp7.0/Subtract.dll"]
  - appID: frontendapp
    appDirPath: ./react-calculator/
    appPort: 8080
    daprHTTPPort: 3507
    command: ["node", "server.js"]

Note : netcoreapp3.1 needs to be changed to netcoreapp7.0 for the existing quickstart to work

In the above scenario, go run app.go starts one process which then starts the app process separately.

When dapr stop -f is called using the run template file, it only kills the go run app.go process and not the binary app process forked from it.

But when a binary is built using say go build -o test-app and that binary is run as ./test-app, dapr stop -f kills the application process.

Have tried, send os.Interrupt, syscall.SIGTERM but that does not work as expected.

In dapr stop -f, kill command with process ID is used to kill the process.

ps output with pid and ppid

ps aj | grep go
user 94976 37431 94975      0    2 S+   s001    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox go
user 94930 94924 94924      0    1 S+   s005    0:00.21 go run app.go
user 94952 94930 94924      0    1 S+   s005    0:00.01 /var/folders/8n/vhq7f8w1419g3t4ww_46_tlr0000gn/T/go-build2832959224/b001/exe/app

Note that both go run app.go and ....../exe/app belong to the same process group, 94924

Release Note

RELEASE NOTE:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions