将瘦网络服务器作为 Windows 服务运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4370049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run thin webserver as a windows service
提问by Stefano
i'm trying to deploy in production Redmine application. I heard that thin is the fastest ruby on rails webserver so I installed it. Now I have a really simple problem: i must start it every time i reboot the machine via cmd because there isn't a prebuilt windows service or something similar that allow me to autostart it. How could i fix the problem? I saw that there is a bat file, so i tried to make a C# windows service like this and it starts correctly but if I stop it the service stops but the webserver is still active and it will never shutdown. The only way to stop thin is to reboot the machine. Maybe I'm wrong, could someone post an example of how should i run thin as a windows service?
我正在尝试在生产 Redmine 应用程序中部署。我听说 Thin 是 Rails 网络服务器上最快的 ruby,所以我安装了它。现在我有一个非常简单的问题:每次我通过 cmd 重新启动机器时我都必须启动它,因为没有预构建的 Windows 服务或类似的东西可以让我自动启动它。我怎么能解决这个问题?我看到有一个 bat 文件,所以我尝试制作一个像这样的 C# windows 服务,它可以正确启动,但是如果我停止它,服务就会停止,但网络服务器仍然处于活动状态,并且永远不会关闭。停止精简的唯一方法是重新启动机器。也许我错了,有人可以发布一个我应该如何将瘦身作为 Windows 服务运行的示例吗?
回答by nathanvda
i've written a blogpostabout this a while ago, but most of it should still be applicable. Hope it helps.
不久前我写了一篇关于此的博客文章,但其中大部分内容应该仍然适用。希望能帮助到你。
But to be honest, i always deploy on windows using the mongrel-service gem, and configure an apache in front to load-balance between 3 mongrels. Much easier.
Also the big advantage for me was that if something went wrong with thin
-service, it didn't restart automatically, while the mongrel-service guards your mongrel process, and if it for whatever reason goes down, it will restart it again. For me that was something i could not miss.
但老实说,我总是使用 mongrel-service gem 部署在 Windows 上,并在前面配置一个 apache 以在 3 个 mongrel 之间进行负载平衡。容易多了。对我来说还有一个很大的好处是,如果thin
-service 出现问题,它不会自动重启,而 mongrel-service 会保护你的 mongrel 进程,如果它出于任何原因出现故障,它会再次重启。对我来说,这是我不能错过的。