root path issues when server is run as a daemon

ⅰ亾dé卋堺 提交于 2019-12-24 08:58:57

问题


i have several views, as well as some gems, that access the filesystem. this seems to work fine until i run the server as a daemon. rails (4.2.3)

for example in one of my views I access the README file in the root of the app

File.read('README.md')

when running as a daemon, i get the error No such file or directory @ rb_sysopen - README.md

the error page shows the Rails.root path, which is correct. i CAN fix this problem by doing:

File.read("#{Rails.root}/README.md")

however this issue breaks more than just my views. It would seem an issue with the rails server.


回答1:


This is how daemonized process works - chdir to / or another working directory. Some programs allow you to specify working directory for daemon process. For example puma server uses current directory by default so it might work for you.



来源:https://stackoverflow.com/questions/31095871/root-path-issues-when-server-is-run-as-a-daemon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!