Precache pages on server startup/app install/publish

Is there a way to define some js code to run on server startup or app install or content publish?

1 Like

I would like this as well, though for a different use case.

For example when upgrading an app that introduces changes in the content structure. Say you rename a field, or split something up, you might want to run an upgrade-script that makes the neccessary changes in existing content.

Specifically, this is relevant for my formbuilder app. Currently, I store both forms, input elements and responses as content that is accessible from the content studio.

Once the node API is accessible (I heard rumors of this coming in 6.8 or 6.9), I want to create an admin tool to handle both creation of forms and browsing/reporting of responses. The actual form would be generated as a content that is accessible in the content studio.

Because of the big change in functionality, I have two options:

  1. Create an entirely new app, which would make the current one useless for anyone that uses it now.
  2. Or run an upgrade script. Of course, I could create a batch script to run for upgrading outside of Enonic, but I see this as in contradiction with the Marketplace idea.

Having the option of defining scripts to run when upgrading, which would have to be aware of previous and current version, would be a really nice feature!

Yes, we will need this eventually. It’s not possible right now without involving Java. But we are thinking of adding some main.js file that you can export started and stopped functions that execute in the lifecycle.

1 Like

We have added event system for serverside Javascript in our backlog.