-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc2pdf.rb
32 lines (32 loc) · 889 Bytes
/
doc2pdf.rb
1
2
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
require 'rubygems'
require 'daemons'
require 'fileutils'
require 'paths'
dir = File.expand_path(File.join(File.dirname(__FILE__)))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp'),
:backtrace => true,
:log_output => true
}
include Paths
Daemons.run_proc('doc2pdf', daemon_options) do
loop do
files = Dir.glob("#{SOURCE_PATH}/*")
files.each do |file|
begin
file = file.scan(/.+\/(\d+)/).first.first
system "#{JODCONVERTER} #{origin_file_path file} #{pdf_file_path file}"
if File.exist?("#{pdf_file_path file}")
puts "#{pdf_file_path file}"
FileUtils.rm "#{SOURCE_PATH}/#{file}"
end
rescue => e
FileUtils.rm "#{SOURCE_PATH}/#{file}"
puts e.message
end
end
sleep 0.5
end
end