0

インデックス ページを読み込まずに、SuckerPunch のバックグラウンド ジョブを開始する方法を見つけようとしています。

今、私がしていることは次のとおりです。

$ rails server #localhost:3000 でサーバーを起動します

次に、ブラウザの URL に移動し、localhost:3000 と入力します。

これにより、SuckerPunch ジョブがトリガーされ、実行が開始されます。

私のapplication_controller.rb

class ApplicationController < ActionController::Base
    
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception

    # call job on application start
    TestEchoJob.new.async.perform("Download CMS Data")
    GetImages.new.async.perform
    DeleteImages.new.async.perform
    SendLead.new.async.perform

end

そこでジョブを呼び出します。私が望むものを達成できるように、それらを置くことができる別の場所があるのではないかと考えています.

httpリクエストではなく、サーバーの起動時にジョブを開始します。

4

1 に答える 1