rest-ftp-daemon 0.100.2 → 0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rest-ftp-daemon +15 -10
- data/lib/rest-ftp-daemon.rb +0 -2
- data/lib/rest-ftp-daemon/api/job_presenter.rb +0 -1
- data/lib/rest-ftp-daemon/api/jobs.rb +2 -3
- data/lib/rest-ftp-daemon/api/root.rb +5 -13
- data/lib/rest-ftp-daemon/constants.rb +1 -2
- data/lib/rest-ftp-daemon/job.rb +2 -7
- data/lib/rest-ftp-daemon/job_queue.rb +0 -2
- data/lib/rest-ftp-daemon/logger_pool.rb +0 -1
- data/lib/rest-ftp-daemon/notification.rb +0 -1
- data/lib/rest-ftp-daemon/views/dashboard.haml +2 -1
- data/lib/rest-ftp-daemon/views/dashboard_jobs.haml +2 -1
- data/lib/rest-ftp-daemon/worker_pool.rb +1 -1
- data/rest-ftp-daemon.yml.sample +7 -7
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b3c42331f0e483617809300fcc7b6623e94e617b
         | 
| 4 | 
            +
              data.tar.gz: 0184e556177357a18e19a686d3fc3ae852dcbffd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ead761e0002d4cfda4409fd43dd1c5828040b204fadb2286898c31ccd428edc41be0dd3c83a334d4c0c35770c5bd77856c3665279b539ca3614460990e5b78c6
         | 
| 7 | 
            +
              data.tar.gz: 0518b79a4037e122c99d6ce50e660724f1db21693c0e5abfeeab319f6759dfce66461aaf7bc999500e967f833c67660fbadfa6a00f241be65c6b154099021ab7
         | 
    
        data/bin/rest-ftp-daemon
    CHANGED
    
    | @@ -18,8 +18,9 @@ puts | |
| 18 18 | 
             
            options = {}
         | 
| 19 19 | 
             
            parser = OptionParser.new do |opts|
         | 
| 20 20 | 
             
              opts.banner = "Usage: #{File.basename $0} [options] start|stop|restart"
         | 
| 21 | 
            +
              opts.on("-c", "--config CONFIGFILE")                                 { |config| APP_CONF = config }
         | 
| 21 22 | 
             
              opts.on("-e", "--environment ENV")                                   { |env| APP_ENV = env }
         | 
| 22 | 
            -
              opts.on("", | 
| 23 | 
            +
              opts.on("",   "--dev")                                               { APP_ENV = "development" }
         | 
| 23 24 | 
             
              opts.on("-p", "--port PORT", "use PORT")                             { |port| options["port"] = port.to_i }
         | 
| 24 25 | 
             
              opts.on("-w", "--workers COUNT", "Use COUNT worker threads")         { |count| options["workers"] = count.to_i }
         | 
| 25 26 | 
             
              opts.on("-d", "--daemonize", "Run daemonized in the background")     { |bool| options["daemonize"] = true }
         | 
| @@ -28,27 +29,31 @@ parser = OptionParser.new do |opts| | |
| 28 29 | 
             
              opts.on("-u", "--user NAME", "User to run daemon as (use with -g)")  { |user| options["user"] = user }
         | 
| 29 30 | 
             
              opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)"){ |group| options["group"] = group }
         | 
| 30 31 | 
             
              opts.on_tail("-h", "--help", "Show this message")                    { puts opts; exit }
         | 
| 31 | 
            -
              opts.on_tail('-v', '--version', "Show version (#{APP_VER})") | 
| 32 | 
            +
              opts.on_tail('-v', '--version', "Show version (#{APP_VER})")         { puts APP_VER; exit }
         | 
| 32 33 | 
             
            end
         | 
| 33 34 | 
             
            begin
         | 
| 34 35 | 
             
              parser.order!(ARGV)
         | 
| 35 36 | 
             
              command = ARGV.shift
         | 
| 36 37 | 
             
              unless ["start", "stop", "restart"].include? command
         | 
| 37 38 | 
             
                puts parser
         | 
| 38 | 
            -
                exit  | 
| 39 | 
            +
                exit 11
         | 
| 39 40 | 
             
              end
         | 
| 40 41 | 
             
            rescue OptionParser::InvalidOption => e
         | 
| 41 42 | 
             
              puts "EXITING: option parser: #{e.message}"
         | 
| 42 | 
            -
              exit  | 
| 43 | 
            +
              exit 12
         | 
| 43 44 | 
             
            end
         | 
| 44 45 |  | 
| 45 | 
            -
            #  | 
| 46 | 
            -
             | 
| 46 | 
            +
            # Build configuration file path from options
         | 
| 47 | 
            +
            APP_CONF ||= File.expand_path "/etc/#{APP_NAME}.yml"
         | 
| 48 | 
            +
            unless File.exists? APP_CONF
         | 
| 49 | 
            +
              puts "EXITING: cannot read configuration file: #{APP_CONF}"
         | 
| 50 | 
            +
              exit 13
         | 
| 51 | 
            +
            end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            # Load helpers and config, and merge options from ARGV into settings
         | 
| 47 54 | 
             
            [:helpers, :config].each do |lib|
         | 
| 48 55 | 
             
              require File.expand_path("#{app_root}/lib/rest-ftp-daemon/#{lib.to_s}")
         | 
| 49 56 | 
             
            end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
            # Merge options from ARGV into settings
         | 
| 52 57 | 
             
            Settings.merge!(options)
         | 
| 53 58 |  | 
| 54 59 | 
             
            # Display compiled configuration
         | 
| @@ -67,10 +72,10 @@ puts | |
| 67 72 | 
             
            if ["start"].include? command
         | 
| 68 73 | 
             
              if Settings['port'].nil?
         | 
| 69 74 | 
             
                puts "ABORTING: Network port is missing"
         | 
| 70 | 
            -
                exit  | 
| 75 | 
            +
                exit 14
         | 
| 71 76 | 
             
              elsif RestFtpDaemon::Helpers.local_port_used?(Settings['port'])
         | 
| 72 77 | 
             
                puts "ABORTING: Network port #{Settings['port']} is already in use"
         | 
| 73 | 
            -
                exit  | 
| 78 | 
            +
                exit 15
         | 
| 74 79 | 
             
              end
         | 
| 75 80 | 
             
            end
         | 
| 76 81 |  | 
    
        data/lib/rest-ftp-daemon.rb
    CHANGED
    
    
| @@ -60,6 +60,7 @@ module RestFtpDaemon | |
| 60 60 | 
             
                  params do
         | 
| 61 61 | 
             
                    requires :source, type: String, desc: "Source file pattern"
         | 
| 62 62 | 
             
                    requires :target, type: String, desc: "Target remote path"
         | 
| 63 | 
            +
                    optional :label, type: String, desc: "Descriptive label for this job"
         | 
| 63 64 | 
             
                    optional :notify, type: String, desc: "URL to get POST'ed notifications back"
         | 
| 64 65 | 
             
                    optional :priority, type: Integer, desc: "Priority level of the job (lower is stronger)"
         | 
| 65 66 | 
             
                    optional :overwrite, type: Boolean, desc: "wether to overwrites files at target server",
         | 
| @@ -69,8 +70,7 @@ module RestFtpDaemon | |
| 69 70 | 
             
                  end
         | 
| 70 71 |  | 
| 71 72 | 
             
                  post '/jobs/' do
         | 
| 72 | 
            -
                    info "POST /jobs"
         | 
| 73 | 
            -
                    # #{params.inspect}"
         | 
| 73 | 
            +
                    info "POST /jobs #{params.inspect}"
         | 
| 74 74 | 
             
                    # request.body.rewind
         | 
| 75 75 | 
             
                    begin
         | 
| 76 76 |  | 
| @@ -99,7 +99,6 @@ module RestFtpDaemon | |
| 99 99 | 
             
                    end
         | 
| 100 100 | 
             
                  end
         | 
| 101 101 |  | 
| 102 | 
            -
             | 
| 103 102 | 
             
                end
         | 
| 104 103 | 
             
              end
         | 
| 105 104 | 
             
            end
         | 
| @@ -20,7 +20,12 @@ module RestFtpDaemon | |
| 20 20 | 
             
            ####### INITIALIZATION
         | 
| 21 21 |  | 
| 22 22 | 
             
                  def initialize
         | 
| 23 | 
            +
                    # Call daddy
         | 
| 23 24 | 
             
                    super
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    # Check that Queue and Pool are available
         | 
| 27 | 
            +
                    raise RestFtpDaemon::MissingQueue unless defined? $queue
         | 
| 28 | 
            +
                    raise RestFtpDaemon::MissingQueue unless defined? $pool
         | 
| 24 29 | 
             
                  end
         | 
| 25 30 |  | 
| 26 31 |  | 
| @@ -54,19 +59,6 @@ module RestFtpDaemon | |
| 54 59 |  | 
| 55 60 | 
             
                  end
         | 
| 56 61 |  | 
| 57 | 
            -
             | 
| 58 | 
            -
            ####### INITIALIZATION
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                  def initialize
         | 
| 61 | 
            -
                    # Call daddy
         | 
| 62 | 
            -
                    super
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    # Check that Queue and Pool are available
         | 
| 65 | 
            -
                    raise RestFtpDaemon::MissingQueue unless defined? $queue
         | 
| 66 | 
            -
                    raise RestFtpDaemon::MissingQueue unless defined? $pool
         | 
| 67 | 
            -
                  end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 62 | 
             
                end
         | 
| 71 63 | 
             
              end
         | 
| 72 64 | 
             
            end
         | 
    
        data/lib/rest-ftp-daemon/job.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ require 'timeout' | |
| 6 6 | 
             
            module RestFtpDaemon
         | 
| 7 7 | 
             
              class Job
         | 
| 8 8 |  | 
| 9 | 
            -
                FIELDS = [:source, :target, :priority, :notify, :overwrite, :mkdir]
         | 
| 9 | 
            +
                FIELDS = [:source, :target, :label, :priority, :notify, :overwrite, :mkdir]
         | 
| 10 10 |  | 
| 11 11 | 
             
                attr_reader :id
         | 
| 12 12 | 
             
                attr_accessor :wid
         | 
| @@ -32,7 +32,6 @@ module RestFtpDaemon | |
| 32 32 |  | 
| 33 33 | 
             
                  # Init context
         | 
| 34 34 | 
             
                  @id = job_id.to_s
         | 
| 35 | 
            -
                  #set :id, job_id
         | 
| 36 35 | 
             
                  FIELDS.each do |field|
         | 
| 37 36 | 
             
                    instance_variable_set("@#{field.to_s}", params[field])
         | 
| 38 37 | 
             
                  end
         | 
| @@ -62,9 +61,6 @@ module RestFtpDaemon | |
| 62 61 | 
             
                end
         | 
| 63 62 |  | 
| 64 63 | 
             
                def close
         | 
| 65 | 
            -
                  # Close logger
         | 
| 66 | 
            -
                  # info "Job.close"
         | 
| 67 | 
            -
                  #@logger.close
         | 
| 68 64 | 
             
                end
         | 
| 69 65 |  | 
| 70 66 | 
             
                def process
         | 
| @@ -308,7 +304,6 @@ module RestFtpDaemon | |
| 308 304 | 
             
                  ftp_connect_and_login
         | 
| 309 305 |  | 
| 310 306 | 
             
                  # Connect remote server, login and chdir
         | 
| 311 | 
            -
                  #path = '/' + Helpers.extract_dirname(@target_url.path).to_s
         | 
| 312 307 | 
             
                  path = Helpers.extract_dirname(@target_url.path).to_s
         | 
| 313 308 | 
             
                  ftp_chdir_or_buildpath path
         | 
| 314 309 |  | 
| @@ -334,6 +329,7 @@ module RestFtpDaemon | |
| 334 329 | 
             
                  @status = :disconnecting
         | 
| 335 330 |  | 
| 336 331 | 
             
                  # Update counters and flags
         | 
| 332 | 
            +
                  $queue.counter_inc :jobs_finished
         | 
| 337 333 | 
             
                  $queue.counter_add :transferred, @transfer_total
         | 
| 338 334 | 
             
                  @finished_at = Time.now
         | 
| 339 335 | 
             
                end
         | 
| @@ -567,7 +563,6 @@ module RestFtpDaemon | |
| 567 563 | 
             
                  # Done
         | 
| 568 564 | 
             
                  set :source_processing, nil
         | 
| 569 565 | 
             
                  info "Job.ftp_transfer finished"
         | 
| 570 | 
            -
                  $queue.counter_inc :jobs_finished
         | 
| 571 566 | 
             
                end
         | 
| 572 567 |  | 
| 573 568 | 
             
                def client_notify signal, error = nil, status = {}
         | 
| @@ -17,12 +17,10 @@ module RestFtpDaemon | |
| 17 17 | 
             
                  @mutex = Mutex.new
         | 
| 18 18 |  | 
| 19 19 | 
             
                  # # Logger
         | 
| 20 | 
            -
                  # @logger = RestFtpDaemon::Logger.new(:queue, "QUEUE")
         | 
| 21 20 | 
             
                  @logger = RestFtpDaemon::LoggerPool.instance.get :queue
         | 
| 22 21 |  | 
| 23 22 | 
             
                  # Identifiers generator
         | 
| 24 23 | 
             
                  @last_id = 0
         | 
| 25 | 
            -
                  #@prefix = SecureRandom.hex(IDENT_JOB_LEN)
         | 
| 26 24 | 
             
                  @prefix = Helpers.identifier IDENT_JOB_LEN
         | 
| 27 25 | 
             
                  info "queue initialized with prefix: #{@prefix}"
         | 
| 28 26 |  | 
| @@ -16,7 +16,6 @@ | |
| 16 16 | 
             
              - else
         | 
| 17 17 | 
             
                - trclass = "warning"
         | 
| 18 18 |  | 
| 19 | 
            -
             | 
| 20 19 | 
             
              %tr{class: trclass}
         | 
| 21 20 |  | 
| 22 21 | 
             
                %td{title: presented.to_json}= job.id
         | 
| @@ -29,6 +28,8 @@ | |
| 29 28 | 
             
                  - unless job.wid.nil?
         | 
| 30 29 | 
             
                    .label.label-default.flag.worker-label= job.wid
         | 
| 31 30 |  | 
| 31 | 
            +
                %td= job.label
         | 
| 32 | 
            +
             | 
| 32 33 | 
             
                %td{title: job.get(:source_path)}
         | 
| 33 34 | 
             
                  =# Helpers.job_method_label job.get(:source_method)
         | 
| 34 35 | 
             
                  = Helpers.highlight_tokens job.source
         | 
    
        data/rest-ftp-daemon.yml.sample
    CHANGED
    
    | @@ -8,8 +8,8 @@ defaults: &defaults | |
| 8 8 | 
             
              host: <%= `hostname`.chomp.split('.').first %>
         | 
| 9 9 |  | 
| 10 10 | 
             
              transfer:
         | 
| 11 | 
            -
                 | 
| 12 | 
            -
                 | 
| 11 | 
            +
                update_every_kb: 1024
         | 
| 12 | 
            +
                notify_after_sec: 10
         | 
| 13 13 |  | 
| 14 14 | 
             
              conchita:
         | 
| 15 15 | 
             
                timer: 10
         | 
| @@ -17,11 +17,11 @@ defaults: &defaults | |
| 17 17 | 
             
                #clean_finished: 600
         | 
| 18 18 |  | 
| 19 19 | 
             
              logs:
         | 
| 20 | 
            -
                thin:    "/ | 
| 21 | 
            -
                queue:   "/ | 
| 22 | 
            -
                api:     "/ | 
| 23 | 
            -
                workers: "/ | 
| 24 | 
            -
                notify:  "/ | 
| 20 | 
            +
                thin:    "/var/log/rftpd-environment-thin.log"
         | 
| 21 | 
            +
                queue:   "/var/log/rftpd-environment-core.log"
         | 
| 22 | 
            +
                api:     "/var/log/rftpd-environment-core.log"
         | 
| 23 | 
            +
                workers: "/var/log/rftpd-environment-work.log"
         | 
| 24 | 
            +
                notify:  "/var/log/rftpd-environment-work.log"
         | 
| 25 25 |  | 
| 26 26 | 
             
            preprod:
         | 
| 27 27 | 
             
              <<: *defaults
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rest-ftp-daemon
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: '0.101'
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bruno MEDICI
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-12- | 
| 11 | 
            +
            date: 2014-12-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |