簡體   English   中英

從Rails應用程序的腳本目錄中運行自定義ruby腳本的正確方法是什么? (生產環境)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM