Deployment fwreinit strategy

Is there a way to “gracefully” do an “fwreinit” during peak hour when everyone is using the system? Is there a way to have the user that’s unfortunate enough to hit the server while the fwreinit is in process to somehow be “paused” and wait for the process to complete, and then gracefully resume?

Also is there a way to reinit only one component, eg UserService, so that deploying only one cfc file won’t mean that I have to reinit the whole app.

You can use the autodeploy module in forgebox: FORGEBOX: AutoDeploy

It allows you to do graceful deployments. You can also try to remove the singleton from WireBox:

wirebox.getScope( "SINGLETON" ).clear( 'key' );

However, the key argument is just on ColdBox 7. If not you would have to do a wirebox.clearSingletons() call. NOTE: This is not safe. because of the way Java does hard memory references. Meaning, objects that are ALREADY constructed and in memory, will NOT be referencing the new singleton, because the old singleton is already in memory. So the only way to be safe is to either reinit or use the clearSingletons(). Just note that ANY request that is executing that is using any of those objects might be erroring out. So not safe.

1 Like

The short answer for a single server is no. The slightly longer answer is detailed in this blog post:

Which basically outlines your choices

  • Reinit quickly and risk a few people get an error or a mainenance page
  • Wait for all running requests to stop, then cleanly reinit, but run the real risk of backing up so many requests in that window, your server falls over

The versions of ColdBox that came out after my blog post above included the ability to do fail-fast reinit (bullet #1).

Now, all that said-- this can be done and quite well if you’re using more than one load balanced server. It can be a ton of work to manually drain servers with a load balancer, but using something like Docker Swarm actually makes this incredibly easy. You literally just refresh the service and the swarm swaps out running replicas in the swarm on-the-fly with no one ever noticing. This also means your app cannot require sticky sessions.

Moving your infrastructure to something like Docker Swarm is not trivial and can be wrought with pitfalls, but the payoffs and endless scalability can be huge. For example, Ortus can deploy a new version of in the middle of the day without a second of downtime for any user which is really nice.

1 Like