Chef:安装Windows服务 [英] Chef: Installing a Windows Service

查看:152
本文介绍了Chef:安装Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个论坛的新手(如果我在错误的位置发帖,我深表歉意),而且对Chef也很新。我到处都是房子,试图弄清楚如何安装Windows服务的清晰示例。

I'm new to this forum (so apologies if I've posted in the wrong place) and also VERY NEW to Chef. I've been all around the houses trying to get a clear example of how to install a Windows service.

基本上,我希望 SC创建的Chef等效。

Basically I want the Chef equivalent of "SC create"

我要使用的配方是:

windows_package "RMS_EU" do
  installer_type :msi
  action :install
  source "c:\Servies\V5.5\EUNTRouteManager\Routing.WindowsService.exe"
end

当我运行此程序时,我收到错误消息,指出msi存在问题。

When I run this I get error saying theres a problem with msi.

我尝试了此脚本的多种变体,并且发现有关如何安装极其稀疏的简单服务的明确信息。

I've tried multiple variants of this script and am finding getting clear information on how to install a simple service incredibly sparse.

知道我哪里出问题了吗?正如我说的那样,当它起作用时,它应该在服务列表中显示为Windows服务。

So does anyone know where I've gone wrong? As I say when this works it should appear as a Windows service in the services list.

文件已经在指定路径上的服务中,并且我正在运行Windows 2008 R2,具有PowerShell v4.0和最新的Chef客户端安装。

The files are already on the service in the path specified, and I've running Windows 2008 R2, with PowerShell v4.0 and the latest Chef client install.

任何帮助都将不胜感激。

Any and all help would be appreciate.

感谢您的反馈

致谢

斯科特

推荐答案

要看的几件事,首先将所有斜杠切换为 c:/Servies/V5.5/EUNTRouteManager/Routing .WindowsService.exe 。 Ruby和大多数编程语言都使用反斜杠作为转义序列来编码通常看不见的字符,例如 \n 用于换行符或 \ \t 选项卡。

A few things to look at, first switch all your slashes around so it is "c:/Servies/V5.5/EUNTRouteManager/Routing.WindowsService.exe". Ruby, and most programming languages, use backslashes as escape sequences to encode characters that you can't normally see, like \n for newlines or \t for tabs.

下一步是软件包安装,您告诉它文件是MSI,但结尾为 .exe ,所以这不太可能。从您的文字来看,我猜您实际上并不是在尝试安装软件包文件,但将来您将必须将安装类型与已知类型之一(MSI,NSIS等)进行匹配。

Next is the package install, you are telling it the file is an MSI but it ends with .exe so this is unlikely. From your text I'm guessing you aren't actually trying to install package file but for the future you'll have to match the install type to one of the known types (MSI, NSIS, etc).

最后,要控制服务,您需要使用 service或windows_service 资源,但是您仍然需要创建它。幸运的是,有一个隐藏的助手:

Finally, to control a service you'll want to use the service or windows_service resources, but you still need to create it. Fortunately there is a hidden helper for this:

ruby_block 'create service' do
  block do
     Chef::Application::WindowsServiceManager.new(
       service_name: "EUNTRouteManager",
       service_display_name: "Something",
       service_description: "Longer something.",
       service_file_path: "c:/Servies/V5.5/EUNTRouteManager/Routing.WindowsService.exe",
     ).run(%w{-a install})
  end
end

service 'EUNTRouteManager' do
  action [:enable, :start]
end

我没有Windows计算机可以对此进行测试,但是我认为它应该可以工作。

I don't have a Windows machine to test that on, but I think it should work.

这篇关于Chef:安装Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆