什么是cloudformation-init :: services中的“支持的服务”?

我试图从cloudformation :: init脚本启动一个自定义的守护进程。 /etc/init.d/myservicefunction齐全; 如果我在cfn-init完成后login,

sudo service myservice start 

performance如预期。

我可以通过两种方法直接从cloudformation脚本启动它,而我似乎无法使其中的任何一个工作:(1)使用cfn-init :: services结构(2)手动启动脚本一个cfn-init ::命令。

(1)这里是config.json作为服务的相关部分:

 "Metadata": { "AWS::CloudFormation::Init": { "configSets": { "ascending": [ "config5" ], "default": [ "config5" ] }, "config5": { "services": { "myservice": { "enabled": "true", "ensureRunning": "true" } } } } } 

哪个产生错误:

 2015-04-16 06:24:25,541 [INFO] -----------------------Starting build----------------------- 2015-04-16 06:24:25,856 [INFO] Running configSets: ascending 2015-04-16 06:24:25,856 [INFO] Running configSet ascending 2015-04-16 06:24:49,942 [INFO] Running config config5 2015-04-16 06:24:49,942 [WARNING] Unsupported service manager: myservice 2015-04-16 06:24:49,945 [INFO] ConfigSets completed 2015-04-16 06:24:49,949 [INFO] -----------------------Build complete----------------------- 

这不会/产生一个正在运行的服务 – 它不会失败,它不会被启动。 这里似乎有一个安装先决条件,我找不到文件。 Yum安装的软件包(nginx,tomcat等)没有任何警告启动。

(2)从服务启动的意义上手动启动服务工作。 但是,服务以自己的用户身份运行,并且cfn服务中似乎丢失了某些东西,因为configuration中的步骤从来没有完成,从而不会执行任何进一步的configuration集。 在config1中挂载/ opt稍微不起作用,我已经包含它来显示在日志中完成的命令。 所以相关的configuration是:

 "Metadata": { "AWS::CloudFormation::Init": { "configSets": { "ascending": [ "config1", "config5" ], "default": [ "config5" ] }, "config1": { "commands": { "mount1": { "command": "umount /dev/xvdc" }, "mount2": { "command": "mount /dev/xvdc /opt" } } }, "config5": { "commands": { "first_launch": { "command": "/etc/init.d/myservice start" } } } } } 

哪个产生日志:

 2015-04-16 06:24:25,541 [INFO] -----------------------Starting build----------------------- 2015-04-16 06:24:25,856 [INFO] Running configSets: ascending 2015-04-16 06:24:25,856 [INFO] Running configSet ascending 2015-04-16 06:24:25,860 [INFO] Running config config1 2015-04-16 06:24:25,876 [INFO] Command mount1 succeeded 2015-04-16 06:24:25,901 [INFO] Command mount2 succeeded 2015-04-16 06:24:49,942 [INFO] Running config config5 

同样,从命令提示符处,service命令会生成一个正在运行的服务和预期的输出:

 bash-4.1$ sudo service myservice start Starting MyService: STARTED MyService Thu Apr 16 06:58:27 EDT 2015 -bash-4.1$ 

cfn-init寻找什么样的回报?

谢谢!

你的服务部分的语法是不完全正确的,即

 "services": { "myservice": { "enabled": "true", "ensureRunning": "true" } } 

如果你看文档http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html#aws-resource-init-services它说…

您可以使用服务密钥来定义实例启动时应启用或禁用哪些服务。 在Linux系统上,使用sysvinit支持该密钥。 在Windows系统上,它使用windows服务pipe理器来支持。

因为你正在运行一个Linux系统你的"services"部分应该看起来像…

 "services": { "sysvinit" : { "myservice": { "enabled": "true", "ensureRunning": "true" } } } 

希望这应该做的伎俩!