Running a process on startup

Hi Everyone,

What is the best way to run a process (cfm file) on startup of the server process ?

I’ve come across using OS level checks and using wget, and also using the onServerStart() process but have not managed to make that work.

Basically I want to run a startup script each time the server starts, to populate server level variables…perhaps there is a way to do this as part of the ‘box server start’ process instead of Luce ??

image846824.png
Tony Burn​

m: +61 481 224 257

e: tony@skaro.com.au | w: www.skaro.com.au

image899879.png

image639233.png

image476992.png

​Disclaimer : The company accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

I’m not sure what you’re doing, but if you are trying to extract configuration, check out using environment variables in stage/production and on dev, use this module:

https://www.forgebox.io/view/commandbox-dotenv

You can get at JVM props and env vars in the server scope in Lucee, or frameworks like ColdBox have helper functions in place to access them.

image846824.png

image899879.png

image639233.png

image476992.png

Hi,

What I am trying to achieve is a process to run on startup of the server (each time it starts) to set a number of server variables, that contain config settings, to save me having to re-read json files every time those settings are needed.

image407608.jpg

Tony Burn​

m: +61 481 224 257

image899879.png

image639233.png

image476992.png

Disclaimer : The company accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

Yep, look at env vars and the dotenv module. but even if you needed to read it in onApplicationStart() and cache the settings in the application scope (or use a framework like Coldbox which gives you much better control over these things) that would work as well so long as you can control the file as necessary per each deployment.

image407608.jpg

image899879.png

image639233.png

image476992.png

Thanks Brad,

I really need on server start, not Application….and I understand that this needs to be in server.cfc but I’m not sure where this file needs to be located to be picked up and actioned on startup - can you (or anyone) advise

I have all my startup processes in a single cfm file at present, so really just need to call this on startup.

image407608.jpg

Tony Burn​

m: +61 481 224 257

image899879.png

image639233.png

image476992.png

Disclaimer : The company accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

Hi Everyone,

I am also looking at the start of the service to execute a first task that starts processes without a server url being called.

Just that if it starts the onApplicationStart function in fact.

I’ve been looking for a while but can’t find.

The idea is that when I deploy my applications (micro-service) the services are launched (scheduling task, service monitoring, etc.)

Christophe