9z0b3t1c / capistrano-resque

Capistrano integration for Resque
MIT License
223 stars 144 forks source link

Running resque as a different user #72

Closed wvengen closed 10 years ago

wvengen commented 10 years ago

I'm deploying with one user, but would like to run resque as the user the app runs with. It'd be great of capistrano-resque would allow to specify a user to run as. This could be either by setting the ssh user option, or using sudo with a specific user.

A simple solution would be to give the option of prepending the command - a capistrano-resque user could add a sudo :as => there.

Would this be a useful feature?

dmarkow commented 10 years ago

While it may be useful, this could be messy to implement; for example, many people may use the rbenv or rvm capistrano plugins as well as rails/bundler plugins. Capistrano logs in and can execute commands such as bundle exec ... but how would this work with something like su -u otheruser bundle exec if that other user account doesn't have rbenv or bundler installed, etc.

I'm closing this for now as I won't be able to get this personally implemented anytime soon, but if you want to take a stab at it and submit a pull request we can get it added.


On a somewhat related note (which I plan on adding to the README): This gem isn't the best approach to managing workers on a production system. What happens if the system reboots or the workers die unexpectedly? Using a system-level process manager (upstart, init.d, etc.) will handle this kind of stuff without having to manually deploy/start resque via capistrano. If you need to restart workers during a deploy, you can just add a super-simple task like sudo service resque restart. And if you need to set a custom user, this can be done in the init/upstart script.

wvengen commented 10 years ago

Thanks for your response, I guess you're right that there is no standard way in which this will just work.

The addition to the README would be useful in my view.