简体   繁体   中英

Cloudfoundry [Cloudfoundry] File.open ruby rails resque class

I am using cloudfoundry. I upload a file and save the file..my routine returns the path and filename

/var/vcap/data/dea/apps/Dwarfquery-0-99065f0be8880d91916257931ed91162/app/tmp/region1-legends10-11-2012-20:53.xml

However the scheduled resque routine which tries to read it using File.Open returns the following error

Errno::ENOENT Error No such file or directory - /var/vcap/data/dea/apps/Dwarfquery-0-99065f0be8880d91916257931ed91162/app/tmp/region1-legends10-11-2012-20:53.xml

This is the path returned by the Upload Server...I have added require 'open-uri' at the top of my Job Class

The line that is failing is

File.open(fpath, 'r+') do |f|

where fpath the the file/directory returning the error

I'm not proficient with ruby at all, but just to clarify:

  • Are the bit that uploads and the Resque routine part of the same "app" (in Cloud Foundry sense?)
  • Are you trying to read the file soon after it has been uploaded, or long after (in particular, after your app has/could have been restarted?)

This is important because:

  1. Each "app" has its own temporary folder and obviously one app can't access another app's filesystem. This also holds if you deployed your app with multiple "instances". Each instance is a separate process that has its own filesystem.
  2. local filesystem storage is ephemeral and is wiped clean every time the app restarts

If you need to access binary data between apps, you will want to use some kind of storage (eg Mongo's GridFS) to have it persisted and visible by both apps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM