タグ: Ruby

  • CANVAS LMSで、メール送信設定を変更したら、エラーでサイトが表示されなくなった

    Bitnami のCANVAS LMSで、メール送信のためのSMTP設定を変更して、再起動したところ、ウェブ画面で下記のエラーが表示された。

    Error ID:
    079f6a97
    Details:
    Web application could not be started by the Phusion Passenger application server.
    
    Please read the Passenger log file (search for the Error ID) to find the details of the error.
    
    You can also get a detailed report to appear directly on this page, but for security reasons it is only provided if Phusion Passenger is run with environment set to development and/or with the friendly error pages option set to on.
    
    For more information about configuring environment and friendly error pages, see:
    

    ログファイル: ApacheのErrorログファイル

    App 1947 output:     /opt/canvaslms-2020.06.17.20-0/ruby/lib/ruby/gems/2.4.0/gems/passenger-5.3.7/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
    App 1947 output:     /opt/canvaslms-2020.06.17.20-0/ruby/lib/ruby/gems/2.4.0/gems/passenger-5.3.7/src/helper-scripts/rack-preloader.rb:188:in `'
    App 1947 output:     /opt/canvaslms-2020.06.17.20-0/ruby/lib/ruby/gems/2.4.0/gems/passenger-5.3.7/src/helper-scripts/rack-preloader.rb:30:in `'
    App 1947 output:     /opt/canvaslms-2020.06.17.20-0/ruby/lib/ruby/gems/2.4.0/gems/passenger-5.3.7/src/helper-scripts/rack-preloader.rb:29:in `
    ' [ E 2020-07-02 05:39:09.0597 1396/Tq age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /opt/canvaslms-2020.06.17.20-0/apps/canvaslms/htdocs/: The application encountered the following error: Permission denied @ rb_sysopen - /opt/canvaslms-2020.06.17.20-0/apps/canvaslms/htdocs/config/outgoing_mail.yml (Errno::EACCES) Error ID: 079f6a97 Error details saved to: /tmp/passenger-error-eo0uMM.html [ E 2020-07-02 05:39:09.0624 1396/T8 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-4] Cannot checkout session because a spawning error occurred. The identifier of the error is 079f6a97. Please see earlier logs for details about the error. [ E 2020-07-02 05:39:09.0631 1396/T8 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-5] Cannot checkout session because a spawning error occurred. The identifier of the error is 079f6a97. Please see earlier logs for details about the error.

    原因と対応としては、編集のために、設定ファイルのコピーして編集したことによるグループの変更およびパーミッションだった。

    他の設定ファイルと同様のグループおよびファイルオーナーに、chown、chgrpで変更。そして、パーミッションがもともと、440だったので、440で再設定した。その後、再起動したところ、正常に表示できるようになった。また、YAMLの設定ファイルの内容で失敗しても、画面上は同じ感じのエラーが表示されるので、注意。

  • Capistranoとは

    Capistrano(カピストラーノ)は、複数のリモートサーバでスクリプトを実行するためのツール。MIT LicenseのOSS。

    Capistranoは、Rubyでかかれており、Ruby on Railsなどのウェブアプリケーションのデプロイツールとして利用される。Rubyでかかれているが、デプロイ対象はPHPなどでも構わない。Ruby on Railsなどは、Gitリポジトリと結びつけて、デプロイの自動化を行うことが多いようだ。

    https://capistranorb.com/

  • Ruby on Railsのアプリをサーバ起動時に自動起動させる方法の調査メモ

    Ruby on Railsのアプリケーションを公開することになったので、サーバとしての実行環境を調べた。

    メモ1

     Ruby on Railsで開発しているときは、「bundle exec rails server -e production」で、実行し、ブラウザでアクセスできるようにする。(俺は開発していないけど)

    productionは、環境変数のRAILS_ENVで指定しているもの。

    メモ2

    Railsのアプリケーションを公開するには、RailsサーバのUnicornをインストールして、これを設定して、起動させることで公開できる。

    Unicornは、起動時に、RAILSアプリケーションのホームのパスで、RAILS_ENVと、Unicornのコンフィグファイルを読み込み起動する。これで、作成したRAILSのアプリケーションが実行されるようになる。

    いろいろと調べていると、公開されるアプリはRAILS_ENV=productionになっている。productionが一般的なようだ。開発されたものを公開する前に確認は必要そうだが。

    RailsサーバのUnicornは、ApacheやNginxと連携させる。これにより、ウェブサーバのアクセスで、Railsの実行部分をUnicornに渡すことができる。

    Railsサーバには、Unicorn以外にもある。

  • 特定バージョンのRuby on Railsをインストールする

    バージョンを指定したRailsのインストールは、下記。

    gem install rails -v インストールするバージョン
    

    インストールされているRailsのバージョンを表示するコマンドは下記。

    rails -v
    

    例: Rails 5.2.2.1をインストールする

    zen:~$ gem install rails -v 5.2.2.1
    Fetching thread_safe-0.3.6.gem
    Fetching tzinfo-1.2.5.gem
    Fetching i18n-1.6.0.gem
    Fetching activesupport-5.2.2.1.gem
    Fetching mini_portile2-2.4.0.gem
    Fetching nokogiri-1.10.1.gem
    Fetching concurrent-ruby-1.1.5.gem
    Fetching rails-dom-testing-2.0.3.gem
    Fetching rails-html-sanitizer-1.0.4.gem
    Fetching loofah-2.2.3.gem
    Fetching builder-3.2.3.gem
    Fetching actionview-5.2.2.1.gem
    Fetching rack-2.0.6.gem
    Fetching crass-1.0.4.gem
    Fetching rack-test-1.1.0.gem
    Fetching erubi-1.8.0.gem
    Fetching actionpack-5.2.2.1.gem
    Fetching activemodel-5.2.2.1.gem
    Fetching activejob-5.2.2.1.gem
    Fetching arel-9.0.0.gem
    Fetching activerecord-5.2.2.1.gem
    Fetching mini_mime-1.0.1.gem
    Fetching mail-2.7.1.gem
    Fetching globalid-0.4.2.gem
    Fetching nio4r-2.3.1.gem
    Fetching actionmailer-5.2.2.1.gem
    Fetching websocket-extensions-0.1.3.gem
    Fetching websocket-driver-0.7.0.gem
    Fetching actioncable-5.2.2.1.gem
    Fetching mimemagic-0.3.3.gem
    Fetching marcel-0.3.3.gem
    Fetching activestorage-5.2.2.1.gem
    Fetching thor-0.20.3.gem
    Fetching rails-5.2.2.1.gem
    Fetching method_source-0.9.2.gem
    Fetching sprockets-3.7.2.gem
    Fetching sprockets-rails-3.2.1.gem
    Fetching railties-5.2.2.1.gem
    Successfully installed concurrent-ruby-1.1.5
    Successfully installed thread_safe-0.3.6
    Successfully installed tzinfo-1.2.5
    
    HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
    But that may break your application.
    
    Please check your Rails app for 'config.i18n.fallbacks = true'.
    If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
    'config.i18n.fallbacks = [I18n.default_locale]'.
    If not, fallbacks will be broken in your app by I18n 1.1.x.
    
    For more info see:
    https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
    
    Successfully installed i18n-1.6.0
    Successfully installed activesupport-5.2.2.1
    Successfully installed mini_portile2-2.4.0
    Building native extensions. This could take a while...
    Successfully installed nokogiri-1.10.1
    Successfully installed rails-dom-testing-2.0.3
    Successfully installed crass-1.0.4
    Successfully installed loofah-2.2.3
    Successfully installed rails-html-sanitizer-1.0.4
    Successfully installed erubi-1.8.0
    Successfully installed builder-3.2.3
    Successfully installed actionview-5.2.2.1
    Successfully installed rack-2.0.6
    Successfully installed rack-test-1.1.0
    Successfully installed actionpack-5.2.2.1
    Successfully installed activemodel-5.2.2.1
    Successfully installed arel-9.0.0
    Successfully installed activerecord-5.2.2.1
    Successfully installed mini_mime-1.0.1
    Successfully installed mail-2.7.1
    Successfully installed globalid-0.4.2
    Successfully installed activejob-5.2.2.1
    Successfully installed actionmailer-5.2.2.1
    Building native extensions. This could take a while...
    Successfully installed nio4r-2.3.1
    Successfully installed websocket-extensions-0.1.3
    Building native extensions. This could take a while...
    Successfully installed websocket-driver-0.7.0
    Successfully installed actioncable-5.2.2.1
    Successfully installed mimemagic-0.3.3
    Successfully installed marcel-0.3.3
    Successfully installed activestorage-5.2.2.1
    Successfully installed method_source-0.9.2
    Successfully installed thor-0.20.3
    Successfully installed railties-5.2.2.1
    Successfully installed sprockets-3.7.2
    Successfully installed sprockets-rails-3.2.1
    Successfully installed rails-5.2.2.1
    Parsing documentation for concurrent-ruby-1.1.5
    Installing ri documentation for concurrent-ruby-1.1.5
    Parsing documentation for thread_safe-0.3.6
    Installing ri documentation for thread_safe-0.3.6
    Parsing documentation for tzinfo-1.2.5
    Installing ri documentation for tzinfo-1.2.5
    Parsing documentation for i18n-1.6.0
    Installing ri documentation for i18n-1.6.0
    Parsing documentation for activesupport-5.2.2.1
    Installing ri documentation for activesupport-5.2.2.1
    Parsing documentation for mini_portile2-2.4.0
    Installing ri documentation for mini_portile2-2.4.0
    Parsing documentation for nokogiri-1.10.1
    Installing ri documentation for nokogiri-1.10.1
    Parsing documentation for rails-dom-testing-2.0.3
    Installing ri documentation for rails-dom-testing-2.0.3
    Parsing documentation for crass-1.0.4
    Installing ri documentation for crass-1.0.4
    Parsing documentation for loofah-2.2.3
    Installing ri documentation for loofah-2.2.3
    Parsing documentation for rails-html-sanitizer-1.0.4
    Installing ri documentation for rails-html-sanitizer-1.0.4
    Parsing documentation for erubi-1.8.0
    Installing ri documentation for erubi-1.8.0
    Parsing documentation for builder-3.2.3
    Installing ri documentation for builder-3.2.3
    Parsing documentation for actionview-5.2.2.1
    Installing ri documentation for actionview-5.2.2.1
    Parsing documentation for rack-2.0.6
    Installing ri documentation for rack-2.0.6
    Parsing documentation for rack-test-1.1.0
    Installing ri documentation for rack-test-1.1.0
    Parsing documentation for actionpack-5.2.2.1
    Installing ri documentation for actionpack-5.2.2.1
    Parsing documentation for activemodel-5.2.2.1
    Installing ri documentation for activemodel-5.2.2.1
    Parsing documentation for arel-9.0.0
    Installing ri documentation for arel-9.0.0
    Parsing documentation for activerecord-5.2.2.1
    Installing ri documentation for activerecord-5.2.2.1
    Parsing documentation for mini_mime-1.0.1
    Installing ri documentation for mini_mime-1.0.1
    Parsing documentation for mail-2.7.1
    Installing ri documentation for mail-2.7.1
    Parsing documentation for globalid-0.4.2
    Installing ri documentation for globalid-0.4.2
    Parsing documentation for activejob-5.2.2.1
    Installing ri documentation for activejob-5.2.2.1
    Parsing documentation for actionmailer-5.2.2.1
    Installing ri documentation for actionmailer-5.2.2.1
    Parsing documentation for nio4r-2.3.1
    Installing ri documentation for nio4r-2.3.1
    Parsing documentation for websocket-extensions-0.1.3
    Installing ri documentation for websocket-extensions-0.1.3
    Parsing documentation for websocket-driver-0.7.0
    Installing ri documentation for websocket-driver-0.7.0
    Parsing documentation for actioncable-5.2.2.1
    Installing ri documentation for actioncable-5.2.2.1
    Parsing documentation for mimemagic-0.3.3
    Installing ri documentation for mimemagic-0.3.3
    Parsing documentation for marcel-0.3.3
    Installing ri documentation for marcel-0.3.3
    Parsing documentation for activestorage-5.2.2.1
    Installing ri documentation for activestorage-5.2.2.1
    Parsing documentation for method_source-0.9.2
    Installing ri documentation for method_source-0.9.2
    Parsing documentation for thor-0.20.3
    Installing ri documentation for thor-0.20.3
    Parsing documentation for railties-5.2.2.1
    Installing ri documentation for railties-5.2.2.1
    Parsing documentation for sprockets-3.7.2
    Installing ri documentation for sprockets-3.7.2
    Parsing documentation for sprockets-rails-3.2.1
    Installing ri documentation for sprockets-rails-3.2.1
    Parsing documentation for rails-5.2.2.1
    Installing ri documentation for rails-5.2.2.1
    Done installing documentation for concurrent-ruby, thread_safe, tzinfo, i18n, activesupport, mini_portile2, nokogiri, rails-dom-testing, crass, loofah, rails-html-sanitizer, erubi, builder, actionview, rack, rack-test, actionpack, activemodel, arel, activerecord, mini_mime, mail, globalid, activejob, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, mimemagic, marcel, activestorage, method_source, thor, railties, sprockets, sprockets-rails, rails after 40 seconds
    38 gems installed
    zen:~$
    zen:~$ rails -v
    Rails 5.2.2.1
    
  • なぜ、Ruby on Railsの動作にNode.jsが必要なのか

    Roby on Railsの環境を用意しないといけなくなったので、Ubuntuでの構築方法を調べていたところ、インストールの中に、Sqlite3-devとNode.jsがあった。Sqlite3-devは、Railsの管理のために必要ということなので、納得。だが、Node.jsがわからない。Node.jsはサーバサイドのJavaScript実行環境なので、rubyは関係ない。関係ないが、Railsには必要だという。気持ち悪いので、調べた。

    それでわかったことは

    • Rails3.1以降、Ubuntuでの開発にはJavaScriptのランタイムが必要になった。
    • JavaScriptのランタイムは、Railsアセットパイプライン(Rails asset pipeline)のコードをコンパイルするのに必要。
    • Node.jsをインストールすることで、サーバサイドでのJavaScriptの実行環境が整う。
    • 参照元: http://railsapps.github.io/installrubyonrails-ubuntu.html

    ということ。Railsの一部をコンパイルするときにJavaScriptのランタイムが必要で、それを準備するための最適解がNode.jsのインストール。すっきり。

    なお、Node.jsをインストールしない場合は、ビルドするRailsアプリケーションのGemfileに下記の設定追加が必要。

     gem 'therubyracer'