I am building a sails app that uses a RabbitMQ do delegate some tasks from the web requests to a worker node. This is pretty much the pattern described in https://devcenter.heroku.com/articles/background-jobs-queueing and https://github.com/heroku-examples/node-articles-nlp.
While I could do a sails.lift() in the worker node, it seems that it would be better to skip the http endpoint (express) and some grunt tasks (bower/frontend dependencies download, less, web resources copy to .tmp, ...).
Is there any way to achieve that?
Thanks!
I need sails in my worker so I can use the waterline ORM and the common services that are defined and exposed in sails.
If you want to use the Sails ORM without the webserver and other web related components, you can use Sails Hooks to configure a minimal application
I wrote a full blog post about how I got background tasks working with SailsJS and Kue, but here's the main hooks part:
require('sails').load({
hooks: {
blueprints: false,
controllers: false,
cors: false,
csrf: false,
grunt: false,
http: false,
i18n: false,
logger: false,
//orm: leave default hook
policies: false,
pubsub: false,
request: false,
responses: false,
//services: leave default hook,
session: false,
sockets: false,
views: false
}
}, function(err, app){
//You can access all your SailsJS Models and Services here
User.findOne(1).then(function(user){
console.log(user)
})
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With