Skip to content
Advertisement

Permission denied in Rails app (Redmine) running with Thin

I’m trying to run Redmine with Thin and nginx as reverse proxy.

My /etc/thin2.1/redmine.yml:

---
pid: /var/run/thin/redmine.pid
group: redmine
wait: 30
timeout: 30
log: /var/log/thin/redmine.log
max_conns: 1024
require: []

environment: production
max_persistent_conns: 512
servers: 4
daemonize: true
user: redmine
socket: /var/run/thin/redmine.sock
chdir: /var/www/projects.mydomain.tld

When I access the site with my web browser I get a 502 Bad Gateway. This is the content of /var/log/thin/redmine.0.log:

>> Writing PID to /var/run/thin/redmine.0.pid
>> Changing process privilege to redmine:redmine
>> Using rack adapter
>> Exiting!
/usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:158:in `delete': Permission denied @ unlink_internal - /var/run/thin/redmine.0.pid (Errno::EACCES)
        from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:158:in `remove_pid_file'
        from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:59:in `block in daemonize'
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/www/projects.mydomain.tld/config/boot.rb:4:in `<top (required)>'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/www/projects.mydomain.tld/config/application.rb:1:in `<top (required)>'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/www/projects.mydomain.tld/config/environment.rb:2:in `<top (required)>'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/www/projects.mydomain.tld/config.ru:3:in `block in <main>'
        from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `instance_eval'
        from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `initialize'
        from /var/www/projects.mydomain.tld/config.ru:1:in `new'
        from /var/www/projects.mydomain.tld/config.ru:1:in `<main>'
        from /usr/lib/ruby/vendor_ruby/rack/adapter/loader.rb:36:in `eval'
        from /usr/lib/ruby/vendor_ruby/rack/adapter/loader.rb:36:in `load'
        from /usr/lib/ruby/vendor_ruby/rack/adapter/loader.rb:45:in `for'
        from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:169:in `load_adapter'
        from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:73:in `start'
        from /usr/lib/ruby/vendor_ruby/thin/runner.rb:185:in `run_command'
        from /usr/lib/ruby/vendor_ruby/thin/runner.rb:151:in `run!'
        from /usr/bin/thin:6:in `<main>'

I don’t understand what causes this error. The .pid files in /var/run/thin/ are owned by root. I tried to give ownership to either redmine and thin but got the same error (these files are recreated upon restart of thin anyways).

I installed Ruby with rbenv. I ran bundle install as root which prompted that doing so will break this application for all non-root users on this machine. According to this answer this shouldn’t be a problem, should it?

EDIT: If I set user and group to root in /etc/thin2.1/redmine.yml the permission denied error disappears. I though it was causing the other error but that one remains.

Advertisement

Answer

For unlink file permission process actually need a permission to write the directory of that file.

So either give redmine permission to write /var/run/thin/ or place pids and socket elsewhere – usually inside app’s shared tmp, rails even creates dirs for these.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement