Open netsensei opened 6 years ago
Thanks for reporting this. You hypothesize that the initializer is ignored. We should verify that.
Can you add this to config/initializers/riiif.rb?
raise 'error'
Then start Passenger. Do you see the above exception being thrown?
@netsensei any updates?
Sorry for the late response.
Yup. I added the 'raise error' line to the initializer. It doesn't get thrown. Oddly enough.
It turns out this is due to a conflict with smart spawning. Please review the debug steps here: https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#the-smart-spawning-method
ruby-2.6.3-p62 passenger-6.0.4 rails-6.0.2.2 Apache httpd-2.4.43
The problem still occurs. My initializer is loaded with puma but not with passenger Any suggested fixes?
UPDATE: Adding 'PassengerSpawnMethod direct' to my apache config solves it, as noted by @CamJN
Issue report
Question 1: What is the problem?
I'm trying to run this application which contains this gem. The gem documentation states that I can change the behaviour of the gem by creating or adapting the initializer file
riiif.rb
to suit my needs. In my case I'm trying to change the first line with this piece of code:Riiif::Image.file_resolver = Riiif::FileSystemFileResolver.new(base_path: '/vagrant/images')
(See the original app code)
However, when I boot the app via passenger, fire up a browser and navigate to a page (i.e. http://rails.box:3000/iiif/2/0000_GRO0026_I/full/full/50/default.jpg) while I have an image file called 0000_GRO0026_I.jpg stored in the /vagrant/images folder on my machine, I get a nasty exception:
#<Riiif::ImageNotFoundError: /vagrant/railsapp/tmp/0000_GRO0026_I.{png,jpg,tif,tiff,jp2}>
The riiif gem is looking for my image in the Rails applications tmp/ folder instead of the one I configured in the intializer.
However, when I run the same the same code via Puma with
rails server
... everything works as expected. The rails app and the gem will play nice and fetch the image from the/vagrant/images
location instead of the appstmp/
folder.The problem happens when I set up passenger + nginx or when I just run passenger standalone in development mode.
So my question: Why does Passenger seem to ignore my
config/initializer/riiif.rb
initializer? Is this initializer file even ignored? Why doesn't Puma throw me an error?I'm running on:
This is the stack trace output:
Question 2: Passenger version and integration mode:
Question 3: OS or Linux distro, platform (including version):
Question 4: Passenger installation method:
Question 5: Your app's programming language (including any version managers) and framework (including versions):
Question 6: Are you using a PaaS and/or containerization? If so which one?
No.
Question 7: Anything else about your setup that we should know?
Installing the application is fairly easy:
bundle install --path vendor
config/initializers/riiif.rb
in a text editorRiiif::Image.file_resolver = Riiif::FileSystemFileResolver.new(base_path: '/vagrant/images')
(change the path to something else for testing purposes)/vagrant/images
(or whatever path)rails server
Now, shut down the server and try again with passenger in standalone mode:
passenger start --address 0.0.0.0 --port 3000
Reload the page and notice now how you get a nasty error.