server started as daemon: Application behaves differently from running in console

Hi,

running our app from its application folder /app via

script/server -p <port>

works fine.

Starting the rails server (2.3.17) as a daemon via

cd /app && script/server -p <port> -d

(e.g. as init.d script)

our application works in parts, but on several actions throws the error
below. It seems that the daemon does not have the correct environment
and cannot find the mentioned file.

How do I bring the daemon to run in the /app folder?

MissingSourceFile (no such file to load --
lib/apn_on_rails/app/helpers/connection_helper):
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails/app/models/apn/app.rb:1
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails/apn_on_rails.rb:62
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails/apn_on_rails.rb:61:in
`each'
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails/apn_on_rails.rb:61
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails.rb:2
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails.rb:1:in `each'
  vendor/gems/apn_on_rails-0.4.2/lib/apn_on_rails.rb:1
  app/models/push_setting.rb:1
  app/models/device.rb:168:in `deactivate'
  app/controllers/api/v2/devices_controller.rb:195:in `destroy'
  app/controllers/api/application_controller.rb:44:in `safe_run'
  app/controllers/application_controller.rb:10:in `log_request'
  /usr/local/lib/ruby/gems/1.8/gems/newrelic_rpm-3.5.0.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:270:in
`perform_action'
  /usr/local/lib/ruby/gems/1.8/gems/newrelic_rpm-3.5.0.1/lib/new_relic/agent/method_tracer.rb:242:in
`trace_execution_scoped'
  /usr/local/lib/ruby/gems/1.8/gems/newrelic_rpm-3.5.0.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in
`perform_action'
  /usr/local/lib/ruby/gems/1.8/gems/newrelic_rpm-3.5.0.1/lib/new_relic/rack/browser_monitoring.rb:12:in
`call'
  /usr/local/lib/ruby/gems/1.8/gems/newrelic_rpm-3.5.0.1/lib/new_relic/rack/developer_mode.rb:24:in
`call'
  lib/api_profiler.rb:27:in `_call'
  lib/api_profiler.rb:23:in `call'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendered rescues/_trace (32.0ms)
Rendered rescues/_request_and_response (1.0ms)
Rendering rescues/layout (internal_server_error)

I had a similar problem. I changed path of the desired file to start with RAILS_ROOT (Rails.root on 3.x I think). and that fixed it.

Norm