将 OTEL 代理作为 Windows 服务运行不起作用

将 OTEL 代理作为 Windows 服务运行不起作用

想要将 Otel collecor 代理作为 Windows 服务运行。因此,下载最新的 Windows 发布包并运行以下命令来创建服务并启动服务。

sc.exe create otelcol displayname= otelcol start= delayed-auto
binPath=
"C:\Users\admin\otelcol-contrib_0.94.0_windows_386\otelcol-contrib.exe
--config C:\Users\admin\Core-Otel.yaml" sc.exe start otelcol

但服务未启动,导致事件查看器出现错误,

otelcol 服务因以下错误而终止:处理控制请求时服务出现异常。

代理版本:0.94.0 操作系统:Windows 服务器

有人能指出将 Otel 代理部署为 Windows 服务的正确方向吗?

更新了文件夹路径的带引号的命令:

sc.exe create otelcol displayname= otelcol start= delayed-auto
binPath=
\""C:\Users\admin\otelcol-contrib_0.94.0_windows_386\otelcol-contrib.exe\"
 --config \"C:\Users\admin\Core-Otel.yaml\"" 
sc.exe description "Otelcol"
sc.exe start otelcol

答案1

要作为系统服务运行,程序必须实现 ServiceMain 协议. 这意味着程序必须被编程为系统服务,而不是任何程序都可以作为服务运行。

有一些程序可以包装任何程序并提供必要的协议:

请注意,要确定程序是否可以在运行服务的非常严格的环境中运行,唯一的方法就是尝试它。

相关内容