Sidekiq Receives SIGHUP When Started Via SSH -t

Home » CentOS » Sidekiq Receives SIGHUP When Started Via SSH -t
CentOS 2 Comments

Hi,

I have a couple of ideas how to fix it, but I’m trying to figure out what’s going on first. I mainly start this program (sidekiq) on Debian systems, and it might be my first time running it under CentOS, so my conjecture is that it has to do with differences between distributions…

Now then, when I run it this way:

ssh user@example.com ‘. ~/.bash_profile && rvm 2.3.1@gemset1 && cd path/to/site && bundle exec sidekiq -C config/sidekiq.yml -d -L
log/sidekiq.log’

it daemonizes itself and stays running. When I add -t switch (ssh -t
…), it gets terminated by SIGHUP.

On Ubuntu it stays running in both cases. What’s happening here? Any suggestions are welcome.

Regards, Yuri

2 thoughts on - Sidekiq Receives SIGHUP When Started Via SSH -t

  • Hi,

    I was able to narrow it down to this ruby script:

    #!/usr/bin/env ruby Process.daemon while true
    sleep 1
    end

    And I can reproduce it on one particular CentOS server, on the other CentOS server it works as on Ubuntu. The CentOS server where I can reproduce the issue is supposed to have vanilla CentOS, but probably not exactly.

    So, when I run it this way on CentOS 7:

    ssh user@example.com -t ‘. ~/.bash_profile && rvm 2.3.1 && cd 1 && ./1.rb’

    script doesn’t stay, without -t it does. Under Ubuntu 16.04 it stays in both cases.

    I tried to reproduce it with bash:

    #!/usr/bin/env bash
    (setsid bash -c ‘exec > /dev/null 2>&1 < /dev/null; while true; do sleep 1 done') & But it behaves consistently across servers (with -t terminates on any server I tried, without -t stays). I might be missing something here. Any ideas are welcome. Like, what to check? Where and what to ask? Regards, Yuri

  • Hi,

    I’ve just found the reason. From what I can see, on the server the process received SIGHUP right after fork. It had no time to switch to new session and detach from controlling terminal. And to work around that one might add sleep to the end:

    ssh user@example.com -t ‘. ~/.bash_profile && rvm 2.3.1 && cd 1 &&
    ./1.rb && sleep 1’

    or wait for pid file to be created, whatever.

    Regards, Yuri

LEAVE A COMMENT