process - 从 azure app service 执行进程
问题描述
我正在运行一个进程以使用来自 proto 文件的 GRPC 工具生成 c# 类。该代码在我的开发机器上运行良好,但一旦部署在 azure 上,进程运行但返回 aExitCode = -1073740791
并且输出为空字符串。
我已经记录了我执行的命令,如果我尝试在Kudu
控制台中执行它工作正常并且 c# 文件按预期生成。
该命令如下所示:
Tools\bin\tools\windows_x86\protoc.exe
-ID:\local\LocalAppData\GrpcTester\0969261f-bfa7-45a8-bba1-7e1ccd3818e7\protos
--csharp_out=D:\local\LocalAppData\GrpcTester\0969261f-bfa7-45a8-bba1-7e1ccd3818e7\csharpfiles
--grpc_out=D:\local\LocalAppData\GrpcTester\0969261f-bfa7-45a8-bba1-7e1ccd3818e7\csharpfiles
--plugin=protoc-gen-grpc="Tools\bin\tools\windows_x86\grpc_csharp_plugin.exe"
D:\local\LocalAppData\GrpcTester\0969261f-bfa7-45a8-bba1-7e1ccd3818e7\protos\mobile_backend.proto
private bool GenerateGRPCCSharpFiles(TestProject testProject)
{
bool succes = false;
var outputFolder = WorkspaceManager.GetProjectSubFolder(testProject.Id.ToString(), WorkspaceManager.CSharpFilesPath);
var protoFilesFolder = WorkspaceManager.GetProjectSubFolder(testProject.Id.ToString(), WorkspaceManager.ProtosPath);
// Install tools
RequireTools().Wait();
var protoc = ProtocPath();
var plugin = ProtocPluginPath();
logger.LogDebug($"GenerateGRPCCSharpFiles : protoc: {protoc}");
logger.LogDebug($"GenerateGRPCCSharpFiles : plugin: {plugin}");
//string protocol = Path.Combine(protoFilesFolder, protoFiles.FirstOrDefault().FileName);
string protocol = Directory.GetFiles(protoFilesFolder).FirstOrDefault();
var command = new string[]
{
$"-I{protoFilesFolder}",
$"--csharp_out={outputFolder}",
$"--grpc_out={outputFolder}",
$"--plugin=protoc-gen-grpc=\"{plugin}\"",
protocol,
};
try
{
using (Process process = new Process())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = protoc;
process.StartInfo.Arguments = string.Join(' ', command);
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
process.WaitForExit();
using (var streamReader = new StreamReader(process.StandardOutput.BaseStream))
{
var response = streamReader.ReadToEnd();
logger.LogDebug($"GenerateGRPCCSharpFiles: Completed output: {response.ToString()}");
}
succes = process.ExitCode == 0;
};
}
catch (Exception ex)
{
throw ex;
}
return succes;
}
解决方案
推荐阅读
- android - 用于 Android 推送通知的动态 Firebase SenderID
- node.js - AWS SQS 消息内置消息属性记录在哪里?
- ggplot2 - 在不使用 ggpaired 的情况下连接观察结果(点和线)
- function - 如何编写我自己的 Haskell sortOn 函数
- java - 无法从 Fedora 30 中删除 java-11-amazon-corretto-devel
- python - 在 Statsmodels Likehood 模型中保留数据标签
- java - 如何在小部件Android中动态添加按钮
- embedded-linux - 您如何从 Yocto 正确构建 gpiod 应用程序?
- ios - 等待在下一次分派时执行的块如何成功?
- php - PHP:接受 base 64 编码图像并将其保存为 JPG