summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@aop.(none)>2012-12-19 17:07:31 +0000
committerroot <root@aop.(none)>2012-12-19 17:07:31 +0000
commit8bf8a6b0494faef24d9c413833d274b152ec0b6e (patch)
tree3d448b00211f269abe331a565bdd8ee06716a4e0
parent19f8eb3261c7e4537173358c6b864fdcc3374db1 (diff)
adjustments for production server
-rw-r--r--Gemfile4
-rw-r--r--aop.gemspec1
-rw-r--r--application.rb14
-rw-r--r--unicorn.rb3
-rw-r--r--views/layout.haml4
5 files changed, 22 insertions, 4 deletions
diff --git a/Gemfile b/Gemfile
index f98dbde..019cd49 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,2 +1,6 @@
+if RUBY_VERSION =~ /1.9/
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_internal = Encoding::UTF_8
+end
source :gemcutter
gemspec
diff --git a/aop.gemspec b/aop.gemspec
index 6b2fe3c..bcc0184 100644
--- a/aop.gemspec
+++ b/aop.gemspec
@@ -28,5 +28,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "rest-client"
s.add_runtime_dependency "rest-client-components"
s.add_runtime_dependency "memcache-client"
+ s.add_runtime_dependency "unicorn"
end
diff --git a/application.rb b/application.rb
index 6eac935..b065a58 100644
--- a/application.rb
+++ b/application.rb
@@ -123,7 +123,7 @@ class Application < Sinatra::Base
end
after '/pug/*' do
- CACHE.add request.path, @result, 7200
+ CACHE.add request.path, @result, 72000 if @result
end
before '/cid/:cid/*' do
@@ -136,6 +136,9 @@ class Application < Sinatra::Base
get '/cid/:cid/?' do
@cid = params[:cid]
+ #local("/pug/cid/#{@cid}/predictions")
+ pid = Process.fork{ local("/pug/cid/#{@cid}/predictions") }
+ Process.detach pid
haml :compound
end
@@ -144,8 +147,9 @@ class Application < Sinatra::Base
if !@cids or @cids.empty?
haml :not_found
elsif @cids.size == 1
- @cid = @cids.first
- haml :compound
+ redirect to("/cid/#{@cids.first}")
+ #@cid = @cids.first
+ #haml :compound
else
haml :select
end
@@ -218,7 +222,11 @@ class Application < Sinatra::Base
end
get '/pug/name/:name' do
+ begin
@result = RestClient.get(File.join(PUG_URI,"compound","name",CGI.escape(params[:name]),"cids","TXT")).split("\n").to_json
+ rescue
+ @result = nil
+ end
end
get '/pug/cid/:cid/image' do
diff --git a/unicorn.rb b/unicorn.rb
index 59b9883..c0441ab 100644
--- a/unicorn.rb
+++ b/unicorn.rb
@@ -1 +1,2 @@
-timeout 600
+worker_processes 6
+timeout 6000
diff --git a/views/layout.haml b/views/layout.haml
index 8ca6a2d..9b423fd 100644
--- a/views/layout.haml
+++ b/views/layout.haml
@@ -3,11 +3,13 @@
%head
%script{:type => "text/javascript", :src => "/jquery-1.8.2.js"}
:javascript
+ $(document).ready(function() { $.ajax({ url: "/cid/#{@cid}/experiments", cache: true }); });
function show(title,element,uri) {
$(element).html("<h4>"+title+"</h4>"+"Retrieving data from PubChem. This may take some time, please be patient."+"<img src=\"/spinning-wait-icons/wait30trans.gif\" alt=\"Searching PubChem\">");
$.ajax({
cache: true,
url: uri,
+ //timeout: 120000;
success: function(data){
data = "<h4>"+title+"</h4>"+"<button onclick='hide(\"" + title + "\",\"" + element + "\",\"" + uri + "\");'>Hide</button>" + data;
$(element).html(data);
@@ -28,6 +30,7 @@
$.ajax({
cache: true,
url: uri,
+ //timeout: 120000;
success: function(data){
$(element).html(data);
},
@@ -44,4 +47,5 @@
%label{:for => 'name'} Compound name:
%input{:type => 'text', :name => 'name', :id => 'name'}
%input{ :type => "submit", :value => "Search" }
+ %em This is an experimental version. Loading data from PubChem can be slow. Please use the "Back" button and retry the offending operation if you have timeout problems.
= yield