运行 ruby exe 文件作为 windows 服务导致错误

Run a ruby exe file as windows service leads to error

我被这个问题困扰了好几天,非常感谢任何帮助。

有一个名为 app.exe 的 ruby 文件位于 "C:\MyApp\app.exe"。这是一个创建系统托盘图标的 windows 应用程序。当我直接点击 app.exe 时,效果很好。但是我想把它作为一个 windows 服务,这样它就一直在系统托盘上(在系统引导给所有用户之后)。

所以我了解到 windows 中的 sc 命令有一些可用于创建服务的命令行参数。我正在这样做:

sc create "testservice" binpath= "C:\Prevas\MyApp\app.exe" displayname= "Test Service

当我开始时:

sc start "testservice"

执行此操作时出现错误:

[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.

无法理解我看到此错误的原因,因为我可以直接启动应用程序。我缺少任何参数或我做错了什么?

谢谢大家

你应该看看 this question
查看 Win32Utils - Ruby library for MS Windows

来自文档,

Note that some libraries, such as win32-api and win32-service, have gems that contain prebuilt binaries so no compiler is necessary for those libraries. Just install them as you would any other gem.

这些实用程序有一些不错的包装器。 win32-service 就是这样一个 gem 将帮助您实现这一目标。

阅读这些 Create a Windows Service with Ruby Part 1 , Part 2 史蒂夫·约翰逊的文章。