Is there a hook fired after all plugins have initialized?

Plugin Development
  • The question is in the title. Basically is there a hook fired after the hook static:app.load has been processed by all plugins. But let me give you some context what I'm trying to achieve, perhaps my design is flawed.

    I'm currently in the process of writing a Prometheus exporter plugin so I can plug some forum metrics into my overall server monitoring system. But I also would like that other plugins could use my plugin to provide further metrics. So I was considering to fire two hooks from this Prometheus plugin.

    • static:nodebb-plugin-prometheus.init - Will fire after initialization passing in the Prometheus client to setup the metrics that should be collected.
    • action:nodebb-plugin-prometheus.metrics - Will fire repeatably when it is time to update the metrics. Can be configured by the user.

    Obviously I only want to fire static:nodebb-plugin-prometheus.init after all plugins have initialized or else they might run into some kind of racing conditions. They couldn't be sure if they would be initialized whenever static:nodebb-plugin-prometheus.init is called. Thus why I would like to fire this hook after initialization was done.

    Now perhaps my idea to use hooks is the wrong approach? Should plugins interact between each other differently? Or is there another problem you see?

  • Theoretically, I think you can ensure your prometheus client is fired last by moving the hook priority down in the ACP plugins ordering menu (although I think that only works with templates 🤔 )

    Attach a "priority" value to the hook?

    I wrote that code sometime in 2013, so I don't actually remember whether a higher priority is later, or a lower priority 😆 Try it out and report back?

  • A higher priority would be later in execution. The hooks are sorted here.

    But the priority is mostly ignored for static and action hooks. Since async.each is used to fire them. async.each works in parallel. Meaning that they will be started in the order of the priority but you have no guarantee that the previous hooks have completed when your hook is called.

  • Would you like us to fire an action hook when static:app.init has finished executing?

Suggested Topics

  • 0 Votes
    12 Posts

    do I have to read the source for each object to learns its methods?

    Yes, you will have to read the source code to see what methods are available.

  • 0 Votes
    1 Posts

    I have begun work on a custom email plugin, and while looking at some others that are available to see how they went about things I noticed that all of the available plugins (at least that I have found so far) already have an entry in the email setup list, regardless of if you have downloaded the associated plugin for that service (ex. Sendgrid, Mailgun, etc).

    So my questions is, if I have a custom email plugin, how exactly would I go about making it selectable / usable by the forum? Does it need to be present in the default email list? Is there a way to have my plugin inject itself into that list of providers or is there a way to override that list so that the forum knows not to use the credentials and settings in there, but instead use the ones in the plugin?

    The only real switch I have found is the "Use an external email server to send emails", which I would imagine that if it is turned off, that would not be much help either.

    If anyone has any insight on how the system works in regards to this and can point me in the right direction, I would appreciate it!


  • 0 Votes
    6 Posts

    Also, just FYI, the docs you used are the old docs, the new ones are at

    You can open an issue at if you wish for a change to be made

  • 0 Votes
    3 Posts

    Of course, however I just felt more comfortable trying to understand what each line of code did! This was more of a learning experience ~

  • 0 Votes
    17 Posts

    That's in my area, PM me details maybe I'll come swing by