In rails, I upload and process image with paperclip + resque, It's consume too much memory and very slow. I want to try node.js to handle these stuff in background.
Is possible route rails and node.js both with the same port?
Some route deal with rails, some route to node.js. for instance,
/users/:user_id/albums(.:format)
/users/:user_id/albums/new(.:format)
/users/:user_id/albums/:id/edit(.:format)
/uploads
Thanks.
POST /uploads to node.js(port 8080) to handle, the others rails. Below is my nginx conf
location = /uploads {
proxy_pass http://127.0.0.1:8080/uploads;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
Thanks @Matthew Ratzloff
No; 10.times { No }
But. Let's say you wanted to do this. You would:
Sure it is. You could use a reverse proxy and forward select paths to your Node.js server and others to your Rails app.
Now, is this a good idea? Well...
A better solution is to continue creating jobs in Resque from Rails but use something like Coffee-Resque to actually process the jobs. That's the route I would go.
Hope that helps!