I have a Rails site which uses the Delayed Job Gem to run a background task. The background task takes a PDF and converts it to a series of images.
The Rails app runs as ‘nobody’ and the delayed job process runs as ‘root’.
The background task runs fine but a problem occurs when the Rails app tries to delete the file which was created by the delayed job process: I get a ‘Permission denied’ message. So ‘nobody’ can’t delete the file which was created by ‘root’.
The problem can be fixed if I set the file/folder permissions with:
chmod -R 755
But this does not affect new files.
I’m deploying my Rails app using Capistrano under the root account.
I’m quite the noob as a linux system admin. Can you suggestion where I’m going wrong?
Many Thanks
So I solved my problem by following sailors advice: basically setup a new user for running the app and deployment. Not sure if this will be useful to anyone else but here’s how I transferred the site to a different user:
Steps
Create a new user called ‘www’
Give www control over the existing files:
Killed existing delayed_job process under root account
Updated the sites vhost to tell passenger which user to run as
Tell cap to deploy with user www in deploy.rb
Now the delayed job process and the sites process run as ‘www’ which solves my problem.