ruby-on-rails – 为什么我不能将站点地图写入具有只读文件系统
发布时间:2020-12-17 03:40:40 所属栏目:百科 来源:网络整理
导读:我正在为我的网站生成站点地图,并暂时将其保存到tmp文件夹,然后上传到我的Amazon AWS账户.我正在使用站点地图生成器和雾宝石来帮助我.到目前为止我有这个…… # In sitemap.rb# Set the host name for URL creationSitemapGenerator::Sitemap.default_host =
我正在为我的网站生成站点地图,并暂时将其保存到tmp文件夹,然后上传到我的Amazon AWS账户.我正在使用站点地图生成器和雾宝石来帮助我.到目前为止我有这个……
# In sitemap.rb # Set the host name for URL creation SitemapGenerator::Sitemap.default_host = "http://mycoolapp.com/" # pick a place safe to write the files #SitemapGenerator::Sitemap.public_path = 'tmp/' # store on S3 using Fog SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new # inform the map cross-linking where to find the other maps SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/" # pick a namespace within your bucket to organize your maps SitemapGenerator::Sitemap.sitemaps_path = '/' SitemapGenerator::Sitemap.create do # Put links creation logic here. # add '/home' add '/about' add '/contact' end 每当我运行heroku运行rake sitemap:create我收到以下错误… In '/app/tmp/': 511 rake aborted! Read-only file system - /sitemap.xml.gz 我真的不知道为什么它不起作用.我甚至通过运行Rails.root.join(‘tmp’)作为初始化程序来确保创建tmp文件夹.任何帮助解决这个问题将不胜感激. 解决方法
不要写入文件系统的根目录
Rake非常清楚错误的来源:
这告诉您rake任务正在尝试将文件写入文件系统的根目录. 如果您没有像Celadon Cedar那样使用ephemeral filesystem support的堆栈,则需要确保写入#{RAILS_ROOT} / tmp而不是文件系统的根目录.我自己没有对此进行测试,但您可以通过将sitemaps_path指向writable directory来解决此问题.例如: SitemapGenerator::Sitemap.sitemaps_path = '/app/tmp' 如果这不起作用,您将必须追踪您的gem或rake任务定义根目录的位置,作为编写sitemap.xml.gz文件的位置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |