Skip to content

how to run the app in a single process? #2

@RamonDonnell

Description

@RamonDonnell

One of the nice features of seneca is being able to wire the app together without changing the plugins.
This is what test-app.js is demonstrating, the entire app can be run in a single process and the plugins are unaware.
But the app will behave differently.
For example to serve the app in a single process the test-app.js can be changed to,

var seneca = require('seneca')()
seneca.use('../lib/api.js')
seneca.use('../lib/doc.js')
seneca.use('../lib/hist.js')
seneca.use('../lib/real.js')

var app = express()

app.use( morgan() )
app.use( express.query() )
app.use( bodyParser.urlencoded({extended: true}) )
app.use( bodyParser.json() )

app.use( serveStatic(__dirname + '/public') )
app.use( seneca.export('web') )
app.listen(3000)

At first look you might think the app will work find but the hist API will return an empty list. As far as I can tell the seneca.add({ role:'hist', kind:'clock' } in real.js will overwrite the same add in hist.js. I'm assuming this is because there is one seneca instance running, where as in the express wiring each server will have its own seneca instance communicating by the bus & queue transports.

Also being able to turn services on/off without breaking the system is a core microservices idea. For example if the express, api and doc servers are started the system runs fine, aside from not responding to the hist and live APIs. Again using the single process wiring above to only include the api and doc plugins then the app will error because it can't find the role:'hist', kind:'clock' pattern.

It seems like a nice idea to wire an app up in a single process, so you can just start coding and then split apart the services later, but once the system starts using buses, queues, etc this is not really possible with a single seneca instance.

Would it make sense to then to wire up a single process app with multiple seneca instances, using in-memory buses and queues transport?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions