node.js - App crashes with "Error: ENOENT" even if persistent folder exist -
lets assume digitalocean/dokku/nodejs/sails app called example.com
, (will be) available via corresponding domain.
i have added persistent storage app by:
dokku docker-options:add example.com run "-v /home/dokku/_work_:/_work_" dokku docker-options:add example.com deploy "-v /home/dokku/_work_:/_work_"
if run dokku run example.com "ls /app/_work_"
or dokku run example.com "ls /app/_work_/uploads"
i can see folder exists , there files/folders there.
ok, in app code want check folders in /app/_work_/uploads
folder , delete old ones. first try list of folders in /app/_work_/uploads
by:
... var p = path.join(sails.config.rootpath, '_work_/uploads'); var dirs = fs.readdirsync(p); ...
the problem code fails following error:
error: enoent: no such file or directory, scandir '/app/_work_/uploads' @ error (native) @ object.fs.readdirsync (fs.js:808:18) @ cleandirs (/app/config/bootstrap.js:36:16) @ object.module.exports.bootstrap (/app/config/bootstrap.js:21:2) @ sails.runbootstrap (/app/node_modules/sails/lib/app/private/bootstrap.js:44:25) @ sails.wrapper [as runbootstrap] (/app/node_modules/sails/node_modules/lodash/index.js:3095:19) @ sails.initialize (/app/node_modules/sails/lib/app/private/initialize.js:68:9) @ wrapper (/app/node_modules/sails/node_modules/lodash/index.js:3095:19) @ /app/node_modules/sails/node_modules/async/lib/async.js:713:13 @ iterate (/app/node_modules/sails/node_modules/async/lib/async.js:262:13) @ /app/node_modules/sails/node_modules/async/lib/async.js:274:29 @ /app/node_modules/sails/node_modules/async/lib/async.js:44:16 @ /app/node_modules/sails/node_modules/async/lib/async.js:718:17 @ /app/node_modules/sails/node_modules/async/lib/async.js:167:37 @ /app/node_modules/sails/lib/app/load.js:184:13 @ /app/node_modules/sails/node_modules/async/lib/async.js:52:16 @ /app/node_modules/sails/node_modules/async/lib/async.js:548:17 @ /app/node_modules/sails/node_modules/async/lib/async.js:542:17 @ _arrayeach (/app/node_modules/sails/node_modules/async/lib/async.js:85:13) @ immediate.taskcomplete (/app/node_modules/sails/node_modules/async/lib/async.js:541:13) @ processimmediate [as _immediatecallback] (timers.js:383:17)
how can if /app/_work_/uploads
, there folders there if check manually?
it turned out event if have files visible via ls
command directly , through docker run <app> <command>
application cannot see them. in order fix instead of
dokku docker-options:add example.com run "-v /home/dokku/_work_:/_work_"
you have add /app/
second part of command by
dokku docker-options:add example.com run "-v /home/dokku/_work_:/app/_work_"
you same ls
or dokku run ..
outputs but, important, app able access files.
i appreciate if link me on why ls
worked in both cases, adding /app
prefix problem solved.
Comments
Post a Comment