简体   繁体   中英

remote ssh command not exiting

I have a restart script written in 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

running the code from the local machine works:

ruby etc/control_app.rb restart production

but running it from remote ssh (jenkins machine, after code change) doesn't exit .

gcloud compute ssh remote_server --zone us-central1-a --command "cd /path/to/app; ruby etc/control_app.rb restart production"
  1. if i edit the script and put exit(0) at first then it exits.

  2. I know it get to the exit(0) because I have placed a print directly above it.

eventually it was the actual script. it was running a python script

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

added & at the end

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM