-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1a856b
commit 3134b72
Showing
9 changed files
with
71 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'net/ssh' | ||
require 'net/scp' | ||
class ImageJob | ||
@queue = :simple | ||
|
||
def self.perform | ||
# здесь делаем важные и полезные вещи | ||
@hostname = "192.168.1.100" | ||
@username = "margo" | ||
@neural_path = "/home/margo/neural-style-master" | ||
@password = "(ntvg123" | ||
|
||
begin | ||
# Sent task for image | ||
Net::SSH.start(@hostname, @username, :password => @password) do |ssh| | ||
output = ssh.exec!("hostname") | ||
unless output.nil? | ||
res = ssh.exec!("rm -rf #{@neural_path}/output/*") | ||
ssh.open_channel do |c| | ||
comm = "cd #{@neural_path} && export PATH=$PATH:/home/margo/torch/install/bin" | ||
comm += " && th neural_style.lua -gpu -1 -image_size 50 -num_iterations 100" | ||
comm += " -style_image input/template.jpg -content_image input/input.jpg -output_image output/out.png" | ||
comm += " > output/output.log 2> output/error.log &" | ||
c.exec(comm) | ||
end | ||
end | ||
end | ||
rescue | ||
return "Unable to connect to start process" | ||
end | ||
begin | ||
# Downloads files | ||
Net::SCP.download!(@hostname, @username,"#{@neural_path}/output/out.png", "/home/matthew/RubymineProjects/ostagram/tmp/output/out.png", :ssh => { :password => @password }) | ||
rescue | ||
return "Unable to connect to download result" | ||
end | ||
# sent mail | ||
# puts "Job is done" | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# This file is used by Rack-based servers to start the application. | ||
|
||
require 'resque/server' | ||
require ::File.expand_path('../config/environment', __FILE__) | ||
run Rails.application | ||
run Rack::URLMap.new "/" => Ostagram::Application, "/resque" => Resque::Server.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
uri = URI.parse("redis://localhost:6379/") | ||
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) | ||
|
||
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'resque/tasks' | ||
task "resque:setup" => :environment |