Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Producded a remote_latex script to test the compiling functions of th…

…e clsi. Had to stop using a chrooted latex to allow the wildcard filesystem to work
  • Loading branch information...
commit 8294ec8f16708a1d0c5d46d8b96355efaa855171 1 parent e80efbb
James authored
View
2  app/controllers/clsi_controller.rb
@@ -13,7 +13,7 @@ def compile(xml_request)
begin
@compile = Compile.new_from_request(xml_request)
@compile.compile
- rescue => e
+ rescue CLSI::Error => e
return xml.compile do
xml.status('failed parse', :reason => e.message)
end
View
8 app/models/compile.rb
@@ -131,15 +131,17 @@ def pre_compile
# Runs LaTeX on files
def do_compile
compile_directory = File.join(LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT, self.project.unique_id)
+ wildcard_fs_directory = File.join(WILDCARD_FS_DIR_RELATIVE_TO_CHROOT, self.project.unique_id)
env_variables = "TEXMFOUTPUT=\"#{compile_directory}\" " +
- "TEXINPUTS=\"#{compile_directory}:$TEXINPUTS\" " +
+ "TEXINPUTS=\"$TEXINPUTS:#{compile_directory}:#{wildcard_fs_directory}\" " +
"BIBINPUTS=\"#{compile_directory}:$BIBINPUTS\" " +
"BSTINPUTS=\"#{compile_directory}:$BSTINPUTS\" "
latex_command = "#{env_variables} #{LATEX_COMMAND} -interaction=batchmode " +
"-output-directory=\"#{compile_directory}\" -no-shell-escape " +
- "-jobname=output #{self.root_resource_path} > /dev/null"
+ "-jobname=output #{self.root_resource_path}"
+ print latex_command
bibtex_command = "#{env_variables} #{BIBTEX_COMMAND} " +
- "#{self.root_resource_path} > /dev/null"
+ "#{self.root_resource_path}"
warn 'warning: latex command has no time out functionality'
system(latex_command)
View
18 config/latex_config.rb
@@ -1,6 +1,14 @@
-LATEX_CHROOT_DIR = File.join(RAILS_ROOT, 'latexchroot')
-LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT = 'compiles'
-LATEX_COMPILE_DIR = File.join(LATEX_CHROOT_DIR, LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT)
-LATEX_COMMAND = File.join(RAILS_ROOT, 'chrootedlatex')
-BIBTEX_COMMAND = File.join(RAILS_ROOT, 'chrootedbibtex')
+#LATEX_CHROOT_DIR = File.join(RAILS_ROOT, 'latexchroot')
+#LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT = 'compiles'
+#LATEX_COMPILE_DIR = File.join(LATEX_CHROOT_DIR, LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT)
+#WILDCARD_FS_DIR_RELATIVE_TO_CHROOT = 'wildcard_fs'
+#WILDCARD_FS_DIR = File.join(LATEX_CHROOT_DIR, WILDCARD_FS_DIR_RELATIVE_TO_CHROOT)
+#LATEX_COMMAND = File.join(RAILS_ROOT, 'chrootedlatex')
+#BIBTEX_COMMAND = File.join(RAILS_ROOT, 'chrootedbibtex')
+LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT = File.join(RAILS_ROOT, 'latexchroot/compiles')
+LATEX_COMPILE_DIR = LATEX_COMPILE_DIR_RELATIVE_TO_CHROOT
+WILDCARD_FS_DIR_RELATIVE_TO_CHROOT = File.join(RAILS_ROOT, 'latexchroot/wildcard_fs')
+WILDCARD_FS_DIR = WILDCARD_FS_DIR_RELATIVE_TO_CHROOT
+LATEX_COMMAND = '/usr/bin/pdflatex'
+BIBTEX_COMMAND = '/usr/bin/bibtex'
View
3  config/server_config.rb
@@ -1,4 +1 @@
SERVER_ROOT_DIR = File.join(RAILS_ROOT, 'public')
-
-WILDCARD_RESOURCE_FILESYSTEM_DIR = File.join(RAILS_ROOT, 'filesystems/wildcard_resource')
-STATIC_FILESYSTEM_DIR = File.join(RAILS_ROOT, 'filesystems/static')
View
20 script/mount_clsi
@@ -1,18 +1,24 @@
#!script/runner
print "Mounting wildcard filesystem..."
pid = fork{
- Kernel.exec("script/mount_wildcard_resource_filesystem", "#{WILDCARD_RESOURCE_FILESYSTEM_DIR}")
+ Kernel.exec("script/mount_wildcard_resource_filesystem", "#{WILDCARD_FS_DIR}")
}
Process.detach pid
File.open('.wildcard_filesystem_pid', 'w'){|f| f.write(pid.to_s)}
print "Done!\n"
-print "Joining filesystems...\n"
-command = "sudo mount -t aufs -o " +
- "dirs=#{STATIC_FILESYSTEM_DIR}:#{WILDCARD_RESOURCE_FILESYSTEM_DIR}=ro " +
- "none #{LATEX_COMPILE_DIR}"
+#sleep 10
-print "The following command requires root privileges:\n#{command}\n"
-system(command)
+#print "Joining filesystems...\n"
+#command = "sudo mount -t unionfs -o " +
+# "dir=#{STATIC_FILESYSTEM_DIR}:#{WILDCARD_RESOURCE_FILESYSTEM_DIR}=ro " +
+# "none #{LATEX_COMPILE_DIR}"
+
+#command = "sudo mount -t aufs -o " +
+# "br=#{STATIC_FILESYSTEM_DIR}:#{WILDCARD_RESOURCE_FILESYSTEM_DIR}=ro " +
+# "none #{LATEX_COMPILE_DIR}"
+
+#print "The following command requires root privileges:\n#{command}\n"
+#system(command)
View
4 script/mount_wildcard_resource_filesystem
@@ -3,6 +3,10 @@
require 'fusefs'
class WildcardResourceFS < FuseFS::FuseDir
+ def contents(path)
+ print "contents: #{path}\n"
+ end
+
def file?(path)
print "file?: #{path}\n"
WildcardResourceFilesystem.file?(path)
View
59 script/remote_latex
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+require 'webrick'
+include WEBrick
+require "soap/wsdlDriver"
+require 'rexml/document'
+
+unless ARGV.size == 2
+ puts "Usage: #{$0} <clsi-host> <filename>"
+ exit
+end
+host = ARGV[0]
+filename = ARGV[1]
+
+#s = HTTPServer.new(
+# :Port => 2000,
+# :DocumentRoot => Dir::pwd
+#
+
+# Start resources server
+#print "Starting resources server...\n"
+#pid = fork{
+# trap("INT"){ s.shutdown }
+# s.start
+#}
+
+# Create SOAP driver
+wsdl = "#{host}/Clsi/wsdl"
+clsi = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+token = clsi.getToken
+
+print "Sending compile request...\n"
+response = clsi.compile(<<-EOS
+ <compile>
+ <token>#{token}</token>
+ <resources>
+ <resource path='main.tex'>#{File.read(filename)}</resource>
+ <resource path='*' url='http://localhost:2000/%path%' />
+ </resources>
+ </compile>
+EOS
+)
+
+# Shutdown resources server
+#Process.kill('INT', pid)
+
+# Parse response
+parser = REXML::Document.new response
+
+status = parser.elements['compile'].elements['status'].text
+print "Compile status: #{status}\n"
+
+unless parser.elements['compile'].elements['output'].nil?
+ print "The following files were returned:\n"
+ for file in parser.elements['compile'].elements['output'].elements
+ print "\t#{file.attributes['url']}\n"
+ system("wget #{host}/#{file.attributes['url']}")
+ end
+end
+
View
11 script/umount_clsi
@@ -1,13 +1,12 @@
#!script/runner
-print "Unmounting union filesystem..."
-system("sudo umount #{LATEX_COMPILE_DIR}")
-print "Done!\n"
+#print "Unmounting union filesystem..."
+#system("sudo umount #{LATEX_COMPILE_DIR}")
+#print "Done!\n"
print "Unmounting wildcard resource filesystem..."
-system("sudo umount #{WILDCARD_RESOURCE_FILESYSTEM_DIR}")
-print "Done!\n"
-
+#system("sudo umount #{WILDCARD_RESOURCE_FILESYSTEM_DIR}")
pid = File.read('.wildcard_filesystem_pid')
system("kill #{pid}")
FileUtils.rm('.wildcard_filesystem_pid')
+print "Done!\n"
Please sign in to comment.
Something went wrong with that request. Please try again.