[英]What is the correct way to run a custom ruby script from inside the script directory from Rails application? (Production environment)
我嘗試了上述堆棧溢出帖子中的所有答案,但沒有一個起作用
當我用#!/ path / to / my / script / runner替換#!/ usr / bin / env ruby並嘗試運行時
Rails返回:
/var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in Establishment_connection establish_connection': Please install the postgresql adapter:
gem install activerecord-postgresql-adapter (no such file to load -- pg) (RuntimeError) from /var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in
建立連接中等。 。 。
當我保留原始的shebang#!/ usr / bin / env ruby完好無損時,沒有任何命令組合有效。
例如script / my_script -e生產返回:
/var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in Establishment_connection establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified) from /var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in
建立establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified) from /var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in
'...等
./my_script返回:./my_script:沒有這樣的文件或目錄(但我已確認文件在那里)
有什么明顯的我想念的嗎?
我想我可以將其變成rake任務,但是此腳本在dev模式下運行良好。
不要忘記運行chmod a+x my_script
。 順便說一句,嘗試使用RAILS_ENV=production
環境變量運行script/my_script
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.