Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting a server wide variable at startup

Guest
May 09, 2007 May 09, 2007
Anyone have a way to set a server wide variable (likely in the server scope) that gets set on server startup rather than in a specific page request via a cfset.

What I would like to be able to do is set a variable external to any application that describes the servers role (ie. development, integration, staging, production) rather than hardcoding into the applications a test for server ip, name, etc.

Thanks
-Mike

680
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 09, 2007 May 09, 2007
Server scope sounds like it's what you are looking for.
See http://livedocs.adobe.com/coldfusion/7/htmldocs/00001148.htm
Run this:
<cfdump var="#server#">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 09, 2007 May 09, 2007
Like I said in my post, I realize that the server scope is the likely place for the variable. That wasn't my question. I want to be able to set that variable external to my code base so that my code can test the value to determine what setup it should be using.

Ideally I would hope that a parameter could be set in one of the files in the cf_root to indicate the role of the server.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2007 May 09, 2007
That's a new one. I can't think of anything internal to CF that would
accomplish this.

My first idea, assuming a windows world, you could do something in the
services start that would call some resource that would set this for
you. I have no idea how or know for sure this is possible.

My second idea is what might be done in the Java underpinnings. Could
something be done there.

There are several xml files that are parsed at start up, but I have no
idea how, if at all, extensible they are.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2007 May 09, 2007
What about a simpler idea?

A simple text|dat file in a known location on each server with the
server's role in it. This file could then be read and checked, and even
added into the server scope at that time, if desired.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 30, 2007 Aug 30, 2007
Did anyone come up with a solution for this? I desire to do the same thing. I don't want to add code to every single application that checks the server's role. I want that set at server startup.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 30, 2007 Aug 30, 2007
LATEST
Alas I have not yet heard, or discovered a way to do this yet.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources