how to use sidekiq worker to access uploaded file in a rails app on Dokku server

1k views Asked by At

I'm using sidekiq plugin: https://github.com/bigboxsoftware/dokku-sidekiq to enable sidekiq on the server. And the problem is the worker cannot access file in any of app folders.

As the plugin README said

Adds a post-deploy hook to Dokku to automatically deploy a container running a Sidekiq worker

I'm not sure this means my app and sidekiq are running in the different container? I have tried to use mounted folder to store uploaded file

cat /home/dokku/home/PERSISTENT_STORAGE
/home/dokku/shared/temp:/app/public/temp

But it still cannot work.

In rails console, I can use File.open('public/temp/file') to open the file, but once use Sidekiq::Worker.new('public/temp/file'), it raise Errno::ENOENT: No such file or directory error.

What I can do now?

1

There are 1 answers

0
nort On

In this situation Sidekiq is running it's own server (container) thus making it sandboxed from the application server (i.e. might or might not be running on the same physical hardware).

In the situation when you want to "share" anything between application server and sidekiq you need to share with a Database / Datastore. This could be S3, Redis, Postgres or the arguments to the sidekiq job itself.

I have have all of these in production for different purposes.