rackbox-cookbook icon indicating copy to clipboard operation
rackbox-cookbook copied to clipboard

SV Unicorn not loading $HOME?

Open mcurtis opened this issue 11 years ago • 3 comments

Anybody else ran in to this? Rails is unable to launch because $HOME is empty when Unicorn is launched via the sv script provided by rackbox.

I tested echoing $HOME from the script as well, and it's not accessible within sv.

In the interim, I've been able to launch Rails by wrapping the command in bash -c with an export, but this breaks restarting and monitoring.

Here's my run script as it stands now:

#!/bin/bash --login

exec 2>&1
exec bash -c "export HOME=/root; /usr/bin/chpst -u apps:apps \
  /home/apps/appname/current/bin/unicorn \
    -E production \
    -c /etc/unicorn/appname.rb"

mcurtis avatar Jul 11 '13 04:07 mcurtis

Hi @mcurtis I think I met the same problem in another situation.

One of the root causes is because previously, I decided to create 2 separate user accounts, one normal user for deploy code, another system user to run the apps in appbox cookbook. This decision has caused a few issues regarding access permission, and the issue you filed.

I plan to simplify appbox. If we only create 1 normal user account to deploy and run apps. Will this work for you? This will help to resolve many opened issues.

teohm avatar Jul 11 '13 04:07 teohm

@teohm 1 normal account would make sense to me. I pulled your sv restart tasks from https://github.com/teohm/sample-app1/blob/master/config/deploy.rb. Since it's calling "sudo sv restart" the sv script is running as root and chowning it to the apps user.

Should instead the service directory just be owned by the deploy user so that sudo is not required? #6 is similar.

mcurtis avatar Jul 11 '13 17:07 mcurtis

@mcurtis ya, we can work out a solution for that. I might be wrong, but I think runit cookbook installs and starts runit service using root user. I guess that's why I ended up writing sudo sv restart.

teohm avatar Jul 12 '13 03:07 teohm