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

Running multiple services #215

Closed
Gsonovb opened this issue Dec 28, 2021 · 2 comments
Closed

Running multiple services #215

Gsonovb opened this issue Dec 28, 2021 · 2 comments
Labels
need-more-info Needs more information from the submitter

Comments

@Gsonovb
Copy link

Gsonovb commented Dec 28, 2021

I tried to run the tutorial( https://docs.microsoft.com/zh-cn/dotnet/architecture/dapr-for-net-developers/getting-started
Multiple services in the local environment.
But it didn't succeed
Now you can only add multiple services manually, which is very inconvenient.
Want to start management functions for multiple projects (such as build, port number modification, environment variables, etc.)

vscode tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build-myfrontend",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/DaprMultiContainer/MyFrontEnd/MyFrontEnd.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "build-mybackend",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/DaprMultiContainer/MyBackEnd/MyBackEnd.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "appId": "MyFrontEnd",
            "appPort": 6001,
            "grpcPort": 50001,
            "httpPort": 3500,
            "metricsPort": 29090,
            "profilePort": 27777,
            "label": "myfrontend-daprd-debug",
            "type": "daprd",
            "dependsOn": "build-myfrontend"
        },
        {
            "appId": "MyFrontEnd",
            "label": "myfrontend-daprd-down",
            "type": "daprd-down"
        },
        {
            "appId": "MyBackEnd",
            "appPort": 6002,
            "grpcPort": 50002,
            "httpPort": 3502,
            "metricsPort": 29091,
            "profilePort": 27778,
            "label": "mybackend-daprd-debug",
            "type": "daprd",
            "dependsOn": "build-mybackend"
        },
        {
            "appId": "MyFrontEnd",
            "label": "mybackend-daprd-down",
            "type": "daprd-down"
        }
    ]
}

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch myfrontend with Dapr",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "myfrontend-daprd-debug",
            "program": "${workspaceFolder}/DaprMultiContainer/MyFrontEnd/bin/Debug/net6.0/MyFrontEnd.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "ASPNETCORE_URLS": "http://localhost:6001"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            },
            "postDebugTask": "myfrontend-daprd-down"
        },   
        {
            "name": "Launch mybackend with Dapr",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "mybackend-daprd-debug",
            "program": "${workspaceFolder}/DaprMultiContainer/MyBackEnd/bin/Debug/net6.0/MyBackEnd.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)",
                "uriFormat": "http://localhost:%s/swagger/index.html"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "ASPNETCORE_URLS": "http://localhost:6002"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            },
            "postDebugTask": "mybackend-daprd-down"
        },
    ]

}
@philliphoff
Copy link
Member

@ Gsonovb Can you be a little more specific about what didn't work? You should be able to add the Dapr tasks for multiple services through the command palette scaffolding commands. That said, having to explicitly manage the ports for each service is admittedly less than ideal, even after considering that this needs be done only once, as each service is added.

There is another, higher level tool for such orchestration that might be considered: Tye

@philliphoff philliphoff added the need-more-info Needs more information from the submitter label Jan 10, 2022
@philliphoff
Copy link
Member

Will close this for now, but note that there is a feature coming to Dapr to help simplify the multiple services with Dapr scenario (if not necessarily integrated with this extension from the start).

See dapr/cli#1123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-more-info Needs more information from the submitter
Projects
None yet
Development

No branches or pull requests

2 participants