我需要为基于微服务的项目运行多个.net 项目,因此我编写了一个简单的.sh 文件来实现此目的。
#! /bin/sh.
~/start
dotnet run --project "AuthService/API" --no-build;
dotnet run --project "MicroServices/FileUploadManagementService/API" --no-build;
dotnet run --project "MicroServices/ContractFinancialManagementService/API" --no-build;
dotnet run --project "MicroServices/ParameterManagementService/API" --no-build;
dotnet run --project "MicroServices/ProcurementManagementService/API" --no-build;
dotnet run --project "MicroServices/SiteManagementService/API" --no-build;
dotnet run --project "MicroServices/StakeholderManagementService/API" --no-build;
dotnet run --project "MicroServices/SupervisionManagementService/API" --no-build;
dotnet run --project "MicroServices/UserManagementService/API" --no-build;
我的问题是在第一行身份验证服务运行后但没有其他项目启动。我怎样才能解决这个问题?
答案1
您需要&
在每一行的末尾添加,这将在后台运行每个命令(我不确定~/start
是什么,但似乎您不需要添加它&
)。
另外,正如@roaima 在评论中指出的那样,您必须更改/bin/sh.
为(/bin/sh
或者/bin/bash
如果您正在使用bash
)。所以你的代码将变成:
#! /bin/sh
~/start
dotnet run --project "AuthService/API" --no-build &
dotnet run --project "MicroServices/FileUploadManagementService/API" --no-build &
dotnet run --project "MicroServices/ContractFinancialManagementService/API" --no-build &
dotnet run --project "MicroServices/ParameterManagementService/API" --no-build &
dotnet run --project "MicroServices/ProcurementManagementService/API" --no-build &
dotnet run --project "MicroServices/SiteManagementService/API" --no-build &
dotnet run --project "MicroServices/StakeholderManagementService/API" --no-build &
dotnet run --project "MicroServices/SupervisionManagementService/API" --no-build &
dotnet run --project "MicroServices/UserManagementService/API" --no-build &
我还从每一行中删除了它,;
因为您的脚本中不需要它,因为您在新行中运行每个命令。仅;
当您在同一行上运行命令时才需要使用:command1;command2;etc