view · edit · sidebar · attach · print · history

20120820-create-download-item-view-try-multi-process-job-management-by-pid

<< | Index | >>


Summary

  • Thought a solution for Data-Corruption.
  • Created Download-Item View.

Commits

Index


Update Job Module for Process Checking

  • to block running of multi Jobs in same time.
  • to get nodification by E-mail.

Update-Idea Job Module with Proess Checker by pid.

Experiment
module Job 
  LOG_ROOT = File.expand_path('log', PROJECT_ROOT)
  PID_FILE = File.expand_path('job.pid', LOG_ROOT)
  def Job.run opts={}, &block
=>  pid = Job.running_pid
=>  job = File.basename($0)
    system = DRb::DRbObject.new(nil, ODDB.config.server_url)
    DRb.start_service
    begin
=>    if pid 
         puts "Process #{pid} is running"
        # email notification
      else
        File.open(PID_FILE, 'w'){ |fh| fh << [Process.pid, job, Time.now].join(',') }
        puts "#{PID_FILE} is created"
        ODBA.cache.setup
        ODBA.cache.clean_prefetched
        DRb.install_id_conv ODBA::DRbIdConv.new
        system.peer_cache ODBA.cache unless opts[:readonly] rescue Errno::ECONNREFUSED
        block.call ODDB::App.new(:auxiliary => true)
      end 
    ensure
=>    unless pid 
        File.unlink(path)
        puts "#{PID_FILE} is deleted"
        system.unpeer_cache ODBA.cache unless opts[:readonly]
      end 
    end 
  end 
=>def Job.running_pid
    if File.exists?(PID_FILE)
      (File.read(PID_FILE) || '').split(',')[0]
    end 
  end
end

Create download item view

NOTE

There are hidden parameters for download_export.

<input type="hidden" value="gcc" name="flavor">
<input type="hidden" value="de" name="language">
<input id="event" type="hidden" value="checkout" name="event">
<input type="hidden" value="67165720" name="state_id">
<input type="hidden" value=":!create,:!invoice.." name="pointer">
<input type="hidden" value="user" name="zone">
<input type="hidden" value="" name="download[generics.xls]">
<input type="hidden" value="1" name="months[analysis.csv]">
<input type="hidden" value="1" name="months[doctors.csv]">
<input type="hidden" value="1" name="months[doctors.yaml]">
<input type="hidden" value="12" name="months[fachinfo.yaml]">
<input type="hidden" value="12" name="months[index_therapeuticus]">
<input type="hidden" value="12" name="months[interactions.yaml]">
<input type="hidden" value="1" name="months[migel.csv]">
<input type="hidden" value="12" name="months[oddb.csv]">
<input type="hidden" value="12" name="months[oddb2.csv]">
<input type="hidden" value="12" name="months[oddb.yaml]">
<input type="hidden" value="1" name="months[patinfo.yaml]">
<input type="hidden" value="12" name="months[price_history.yaml]">
<input type="hidden" value="12" name="months[price_history.csv]">
<input type="hidden" value="1" name="months[oddb.dat]">
<input type="hidden" value="1" name="months[oddb_with_migel.dat]">
<input type="hidden" value="12" name="months[fachinfos_de.pdf]">
<input type="hidden" value="12" name="months[fachinfos_fr.pdf]">
<input type="hidden" value="1" name="months[compendium_ch.oddb.org.firefox.epub]">
<input type="hidden" value="1" name="months[compendium_ch.oddb.org.htc.prc]">
<input type="hidden" value="1" name="months[compendium_ch.oddb.org.kindle.mobi]">
<input type="hidden" value="1" name="months[compendium_ch.oddb.org.stanza.epub]">
<input type="hidden" value="12" name="months[generics.xls]">
<input type="hidden" value="1" name="months[patents.xls]">
<input type="hidden" value="12" name="months[swissdrug-update.xls]">
<input type="hidden" value="12" name="months[oddbdat]">
<input type="hidden" value="12" name="months[s31x]">
view · edit · sidebar · attach · print · history
Page last modified on August 20, 2012, at 12:02 PM