Skip to content

Asynchronous initialisation process #32

Closed

Description

@daankets

Due to the current implementation of the boot process using this invocation style:

javascript
module.exports = function someBootScript(app) {
  // Init models, ...
  // Setup relationships
  // Other async stuff
};

it is currently not really possible (in a clean way) to have loopback wait with accepting requests until complete finalisation of the boot process. Some asynchronous operations may not yet have finished.

Please adjust this to something like:

module.exports = function someAsyncBootScript(app, done) {
  // Init models, ...
  // Setup relationships
  // Other async stuff that calls done() when ready.
};

And only start the listener after this... It should be fairly easy to implement this using Q.all()...

Activity

  1. raymondfeng commented on Aug 5, 2014

    @raymondfeng
    Member

    The boot() is designed to be synchronous at the moment. We’re open to make it more flexible.

    Thanks,


    Raymond Feng
    Co-Founder and Architect @ StrongLoop, Inc.

    StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

    On Aug 5, 2014, at 12:09 PM, Daan Kets notifications@github.com wrote:

    Due to the current implementation of the boot process using this invocation style:

    javascript
    module.exports = function someBootScript(app) {
    // Init models, ...
    // Setup relationships
    // Other async stuff
    };
    it is currently not really possible (in a clean way) to have loopback wait with accepting requests until complete finalisation of the boot process. Some asynchronous operations may not yet have finished.

    Please adjust this to something like:

    module.exports = function someAsyncBootScript(app, done) {
    // Init models, ...
    // Setup relationships
    // Other async stuff that calls done() when ready.
    };
    And only start the listener after this... It should be fairly easy to implement this using Q.all()...

    —
    Reply to this email directly or view it on GitHub.

  2. bajtos commented on Oct 14, 2014

    @bajtos
    Member

    #50 implemented support for async boot scripts, the feature is available as of v2.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions