Thank a lot Eric.
I am using Ruby 2.3.3 and Unicorn 5.3.
"It sounds like somebody else is sending SIGKILL to a worker..." This line of
yours saved my server.
Actually when I uploads a file, it first goes to /tmp directory and then one of
the worker processes of unicorn uploads it to S3 from there. So, earlier when I
was trying to fix timeout connection error of unicorn, I increased it to 20
minutes and the problem was solved temporarily.
But the problem was that the files that were uploaded temporarily to /tmp
directory, those files do not get deleted from /tmp after they are uploaded to
S3. So, I wrote a script using tmpreaper that cleans the /tmp directory
recursively and removes the files that are 30 min older and added that to cron
service.
After this, as a result of this script, all the files that were required to be
removed, were removed from /tmp directory but again a problem occurred. When I
used "df -h" command to check whether the files are actually deleted or not, it
showed that the space that was taken by uploaded files on my disk has not been
freed :( . So, I searched internet and got to know that any other process was
still using those files, that was why the space on the disk was not freed.
I used ' lsof +L1 | grep "deleted" ' command and found that a process named
'bundle' is still using these deleted files. So, I again wrote a script that
was killing the process that was using a deleted file. Script was using this
command
" lsof +L1 | grep 'deleted' | awk '{print $2}' | xargs kill -9 "
Today, after reading your words, I finally realised that my script was killing
the unicorn worker itself because the command that I was using was killing the
parent of "bundle" process. As "bundle" was a child of Unicorn worker, unicorn
worker was being killed.
So, thanks a lot Eric :)
I was finally able to solve this error because of the direction and hint that
you gave me. But the only thing that I need to find is that what is causing
uploaded files to persist in /tmp directory.