我对 puppet 很陌生,我很确定我犯了一些非常愚蠢的错误。但是我需要让 puppet 在流浪机器上启动德鲁伊集群。我无法提供比这更好的解决方案:
exec { "run_coordinator":
cwd => "/tmp/druid-services-0.6.160/",
command => "java -Xmx256m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath lib/*:config/coordinator io.druid.cli.Main server coordinator",
path => ["/bin", "/usr/bin"],
require => [ Exec["run_zooKeeper"] ],
}
exec { "run_historical":
cwd => "/tmp/druid-services-0.6.160/",
command => "java -Xmx256m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath lib/*:config/historical io.druid.cli.Main server historical",
path => ["/bin", "/usr/bin"],
require => [ Exec["run_coordinator"] ],
}
exec { "run_broker":
cwd => "/tmp/druid-services-0.6.160/",
command => "java -Xmx256m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath lib/*:config/broker io.druid.cli.Main server broker",
path => ["/bin", "/usr/bin"],
require => [ Exec["run_historical"] ],
}
当我运行它时,我得到 /Stage[last]/Install_druid/Exec[run_coordinator]/returns:从 notrun 更改为 0 失败:命令在/xxx/base.pp:xxx 处超出超时 我想我可以简单地添加 & 但是 我确信这不是最干净的方法。有什么建议吗?提前致谢。
最佳答案
当您使用 provider => shell
时,添加 &
可能会起作用。
但是,是的,构建一个简单的脚本来包装实际调用并将其 fork 到后台会更清晰。
#!/bin/sh
if [ "$1" == "-d" ] ; then
$0 &
exit 0
fi
PATH=/bin:/usr/bin
cd /tmp/druid-services-0.6.160/
java -Xmx256m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath lib/*:config/broker io.druid.cli.Main server broker
构建 init
脚本或类似的服务 Controller 并使用服务资源会更干净。
service {
'druid_broker':
ensure => 'running',
enable => true;
}
不过,不要从 /tmp
运行您的服务。这太可怕了。
关于java - 如何让puppet运行java程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26547617/