厨师食谱不运行服务

时间:2013-08-19 15:05:21

标签: chef

我的食谱中有以下代码:

service "myapp" do
  supports :restart => true, :start => true, :stop => true
  action :nothing
end 

bash "install myapp" do
    cwd "/var/lib/myapp"
    code <<-EOH
    npm install myapp
    EOH
    timeout 86400
    notifies :start, "service[myapp]"
end

厨师食谱运行正常,我可以在控制台中看到以下输出:

212.71.1.1   * service[myapp] action start←[0m

然而,该服务并没有真正启动..如果我手动登录并运行'service myapp start'它就可以正常运行..

我尝试使用-VV运行knife bootstrap命令,但控制台上没有提供进一步的信息

1 个答案:

答案 0 :(得分:1)

您已经定义了服务的功能,但没有定义您想要的操作。

service "example_service" do
  supports :status => true, :restart => true, :reload => true
  action [ :enable, :start ]
end

记录here

更新

为什么不使用npm食谱?如果它按照宣传的方式工作,您的配方看起来更像是普通的包安装和服务声明:

npm_package "myapp" do
  version "1.2.3"
  path "/var/lib/myapp"
  action :install
end 

service "myapp" do
  supports :status => true, :restart => true, :reload => true
  action [ :enable, :start ]
end
相关问题