Setting up a global Celluloid pool

161 views Asked by At

I am using a Celluloid pool in a Rails application to offload pdf conversions after a user uploaded files.

I used an initializer to create a global conversion pool for the application.

All went well in my development environment (OS X, thin). And also no problem running it on my CentOS box (Apache, Passenger).

This is basically the initial setup:

config/initializers/converter_pool.rb

require './lib/x/convert_async'

CONVERT_POOL=X::ConvertAsync.pool

lib/X/convert.rb

module X
  class Convert
  end
end

lib/X/convert_async.rb

require_relative 'convert'

module X
  class ConvertAsync < Convert
    include Celluloid
  end
end

At some stage my pool stopped working on the CentOS box (usertest env) but continued ok in my development environment.

Additional note: Pool still worked when the methods updating the images was called through the console. I guess the problem had to do with load order or permissions of some kind.

Not sure what caused it - there was a new Linux kernel and updates to gems.

After various attempts I finally got it working again by initializing the pool after the class definition and removing the initializer for the pool.

module X
  class ConvertAsync < Convert
    include Celluloid
  end
end

CONVERT_POOL=X::ConvertAsync.pool

I still have Questions since I like to understand better what happened.

Does anybody know what might have caused it? It is a bad idea to instantiate a Celluloid pool after the class definition? Are there any potential issues?

Many thanks in advance for anyone who can shed some light :) Cheers, Eugen

0

There are 0 answers