无法获得“远程执行”到启动tomcat

时间:2018-11-01 20:02:43

标签: tomcat terraform tomee oci oracle-cloud-infrastructure

设置实例时,我使用“ remote-exec”执行一些命令,然后通过terraform启动tomcat实例。看起来像这样:

resource "null_resource" "mount_fss_on_DFSrvr" {
depends_on = ["oci_core_instance.DFSrvr",
  "oci_file_storage_export.export_FileListener_FileListenerMount",
]

count = "${var.proddfsrvr_count}"

provisioner "remote-exec" {
  connection {
    agent       = false
    timeout     = "15m"
    host        = "${oci_core_instance.DFSrvr.*.public_ip[count.index % var.proddfsrvr_count]}"
    user        = "opc"
    private_key = "${file(var.ssh_private_key)}"
  }

  inline = [
   "some commands",
    "./catalina.sh start",
    "exit"
  ]
}

}

输出显示tomcat已启动,但是当我查看该实例时,日志显示该实例尚未启动(没有日志记录)。我可以ssh进入实例并运行“ ./catalina.sh start”,它可以正常工作。我也尝试过创建服务并在remote-exec内联命令中运行“ sudo服务tomee start”而不是“ ./catalina.sh start”,但这也不起作用。我在这里做什么错了?

  null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CATALINA_BASE:   /apache-tomee-plus-7.0.4
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CATALINA_HOME:   /apache-tomee-plus-7.0.4
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CATALINA_TMPDIR: /apache-tomee-plus-7.0.4/temp
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using JRE_HOME:        /usr
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CLASSPATH:       /apache-tomee-plus-7.0.4/bin/bootstrap.jar:/apache-tomee-plus-7.0.4/bin/tomcat-juli.jar
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Tomcat started.

2 个答案:

答案 0 :(得分:0)

尝试提供绝对路径,而不要使用 [AbpMvcAuthorize] public class OpenChatHub : Hub, ITransientDependency { public IAbpSession AbpSession { get; set; } public ILogger Logger { get; set; } public OpenChatHub() { AbpSession = NullAbpSession.Instance; Logger = NullLogger.Instance; } public async Task SendGroupMessage(string message, string groupName) { // logic for the SendGroupMessage would be here var msg = new { sendById = AbpSession.UserId, // this will be null at random times message = message }; await Clients.Group(group).SendAsync("receiveChatMessage", msg); } } 之类的./。它可能不会从您认为的地方开始。

第二步删除source ~/tmp/catalina.sh行。安装完成之前,它可能正在退出。在写入磁盘之前,有些事情已经完成。您也可以尝试exit

此外,这是否完全需要sudo权限?

答案 1 :(得分:0)

我在运行python网络应用程序时遇到了同样的问题。我想这里的问题是当您通过remote-exec运行命令时,一旦完成,它就会退出外壳。因此,当您将ssh插入计算机时,它会通过新的shell打开,您应该在命令之前添加nohup,我相信这可以解决问题。那为我做到了。如果希望它在后台运行并退出remote-exec,请使用&。 另外,您可能希望向内联命令添加“ sleep 20”,这将使tomcat有时间在供应者退出之前启动。

inline = [    “一些命令”,     “ nohup ./catalina.sh开始&”,     “睡觉20”,   ]