Class: Admin::DjController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/dj_controller.rb

Instance Method Summary collapse

Instance Method Details

#do_processObject



37
38
39
40
41
42
# File 'app/controllers/admin/dj_controller.rb', line 37

def do_process
  if params[:process]
    `bundle exec script/delayed_job #{params[:process]}`
    flash[:notice] = "Process #{params[:process]}"
  end
end

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/admin/dj_controller.rb', line 3

def index

  if request.post? && params[:delete]
    DelayedJob.delete_all("id = #{params[:delete]} and queue = '#{_sid}'")
    redirect_to "/admin/dj", :notice=>"Job deleted"
  end

  if request.post? && params[:id]
    dj = DelayedJob.where("queue = #{_sid} and id=#{params[:id]}").first
    if dj
      dj.run_at = Time.now
      dj.save
    end
    redirect_to "/admin/dj"
  end

  if request.post? && params[:process]
    do_process
    redirect_to "/admin/dj"
  end

  @delayed_jobs = DelayedJob.where(:queue=>_sid).order("created_at desc").page(params[:page]).per(100).all
 
  @running = false
  if File.exist?("tmp/pids/delayed_job.pid")
    begin
      @pid = File.read("tmp/pids/delayed_job.pid").strip
      Process.getpgid( @pid.to_i )
      @running = true
    rescue Errno::ESRCH
    end
  end
end