【问题标题】:remote ssh command not exiting远程 ssh 命令未退出
【发布时间】:2015-02-12 20:43:21
【问题描述】:

我有一个用 ruby​​ 编写的重启脚本

#!/usr/bin/env ruby

require "#{DIR}/etc/control_helper"


###### MAIN program ################
case action
    when 'start'
         .....

    when 'stop'
          .....
    when 'restart'
        kill_the_old_process_if_needed(PORT_NUM, APP_NAME, APP_FILE_NAME)

        new_pid = start_a_new_process!(ENVIRONMENT, PORT_NUM, APP_FILE_NAME)
#here there is an **exit(0)**
        check_for_success_in_starting_new_process!(hostname, new_pid) 

end

从本地机器运行代码工作:

ruby etc/control_app.rb restart production

但从远程 ssh 运行它(詹金斯机器,代码更改后) 不退出。

gcloud compute ssh remote_server --zone us-central1-a --command "cd /path/to/app; ruby etc/control_app.rb restart production"
  1. 如果我编辑脚本并首先输入exit(0),然后它就会退出。

  2. 我知道它会到达出口 (0),因为我在它的正上方放置了一个打印件。

【问题讨论】:

    标签: linux ssh google-cloud-storage gcloud


    【解决方案1】:

    最终它是实际的脚本。 它正在运行一个 python 脚本

    PYTHON_ENV=#{environment} nohup python #{APP_FILE_NAME}  > #{environment}.log
    

    在末尾添加 &

    PYTHON_ENV=#{environment} nohup python #{APP_FILE_NAME}  > #{environment}.log & 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-12
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      相关资源
      最近更新 更多