Flatpick13
Flatpick13

Reputation: 81

Running multiple sites in one CF instance

I'm running 2 sites (Dev and QA) under one instance of CF 2018. When I send a REST call to a CFC on Dev, the QA instance gets confused and starts delivering pages from the Dev site, probably due to Application or Session vars being changed. I verified that the REST call is using the session vars from Application.cfm for the dev environment, as it should. But the QA instance somehow gets switched over to the Dev folder and starts running cfm modules from there. I can't find where the QA pages are getting redirected. Thanks in advance, for any ideas on things to look at.

Upvotes: 0

Views: 155

Answers (1)

Adrian J. Moreno
Adrian J. Moreno

Reputation: 14859

Both DEV and QA are sharing the same application name and therefore the same application and session variables. You're switching context between requests, based on which domain / environment made the previous request.

In addition, you should convert your Application.cfm to Appliction.cfc and refactor how and when you're defining application and session variables. It feels like the CFM is just setting those values on every request instead of only once, which is why the different requests are switching context.

http://www.learncfinaweek.com/course/index/section/Application_cfc/item/Application_cfc/

You need to run

  • each environment on their own CF instance
  • the application name should be dynamic
  • each instance should point their data sources to their own database.

Isolating the instances allow you to track separate logs based on environment.

Dynamic application names isolates the application's shared scopes from each other.

The data should be separated per environment to isolate in-development DB related changes from QA testing.

https://coldbox.ortusbooks.com/getting-started/configuration/bootstrapper-application.cfc

Your code is in source control. You checkout a copy for DEV and one for QA, each to their own "web root".

/code/DEV/repo
/code/QA/repo

In your Application.cfc:

this.name = hash( getCurrentTemplatePath() );

This creates a dynamic application name based on the current folder path, so DEV and QA will be different and easily isolate the shared scopes. Also helps with local DEV efforts.

It's a bit of work, but there's no way to shortcut this.

Upvotes: 2

Related Questions