danlance
09/16/2022, 1:22 PM{
"name": "${INSTANCENAME:UndefinedInEnvironment}"
}
When we were running CB <= 5.2.0, this would correctly set the name of the server to the passed in environment variable… but following on from upgrading to 5.4.2, the servername is always set to www
- or rather I believe set to the name of the folder the server is started in…
Within the detailed output for warmup-server.sh (in this instance running CB 5.5.2) we see the following:
Starting up container in test mode
Set verboseErrors = true
INFO: Configuration set to non-root user: CBServerUser
Set verboseErrors = true
INFO: CF Engine defined as lucee@5.3.9+133
INFO: Convention .cfconfig.json found at /var/www/.cfconfig.json
INFO: Server Home Directory set to: /usr/local/lib/serverHome
√ | Starting Server
|------------------------------
| start server in - /var/www/
| server name - www
| server config file - /var/www//server.json
| WAR/zip archive already installed.
..and when the server starts - either locally or on AWS, the server name always shows up as www
previously, within the warmup running within the dev ops build script, where the INSTANCENAME
environment variable was not set, we would see UndefinedInEnvironment
shown as the server name, and then when running within local / AWS environments where the environment variable was set, the server name would be set to the environment variable.
This is particularly an issue when viewing servers within Fusion Reactor Cloud dashboard… as we have multiple servers for different applications and environments appear in the dashboard as www - and not the specific app / environment name specified.
All other dynamically set parameters within the server.json - such as the fusionreator settings for cloudgroup, defaultApplicationName etc. which are set from environment variables, appear to be set correctly (so we can for instance see in FR when we dig into the details what app / environment is being run, but on all the menus, all instances appear as www.
Can anyone advise why this behaviour seems to have changed… and if there is something we can do to ensure that the server name is set correctly as it was previously?bdw429s
09/16/2022, 3:27 PMbdw429s
09/16/2022, 3:28 PMbdw429s
09/16/2022, 3:28 PMbdw429s
09/16/2022, 3:29 PMbdw429s
09/16/2022, 3:29 PMbdw429s
09/16/2022, 3:30 PMdanlance
09/16/2022, 3:30 PMFROM ortussolutions/commandbox:3.5.4
and we are running:
RUN ${BUILD_DIR}/util/warmup-server.sh
danlance
09/16/2022, 3:31 PMbdw429s
09/16/2022, 3:32 PMbdw429s
09/16/2022, 3:32 PMdanlance
09/16/2022, 3:32 PMbdw429s
09/16/2022, 3:33 PMbdw429s
09/16/2022, 3:33 PMthen server.json will be ignoredNot ignored, I mean the rest of your settings will be used. But the name itself is locked in the way it works now
danlance
09/16/2022, 3:33 PMbdw429s
09/16/2022, 3:33 PMbdw429s
09/16/2022, 3:34 PMdanlance
09/16/2022, 3:34 PMbdw429s
09/16/2022, 3:34 PMwas that something which was changed between 5.2.0 and 5.4.2?Maybe, you'd need to go read the release notes 🙂
bdw429s
09/16/2022, 3:34 PMdanlance
09/16/2022, 3:35 PMbdw429s
09/16/2022, 3:35 PMdanlance
09/16/2022, 3:35 PMdanlance
09/16/2022, 3:35 PMbdw429s
09/16/2022, 3:35 PMdanlance
09/16/2022, 3:36 PMbdw429s
09/16/2022, 3:36 PMdanlance
09/16/2022, 3:36 PMdanlance
09/16/2022, 3:36 PMbdw429s
09/16/2022, 3:37 PMbdw429s
09/16/2022, 3:37 PMdanlance
09/16/2022, 3:37 PMbdw429s
09/16/2022, 3:37 PMbdw429s
09/16/2022, 3:37 PMbdw429s
09/16/2022, 3:37 PMbdw429s
09/16/2022, 3:38 PMbdw429s
09/16/2022, 3:38 PMbdw429s
09/16/2022, 3:38 PMbdw429s
09/16/2022, 3:39 PMbdw429s
09/16/2022, 3:39 PMdanlance
09/16/2022, 3:39 PMbdw429s
09/16/2022, 3:42 PMdanlance
09/16/2022, 3:43 PMdanlance
09/16/2022, 3:44 PMbdw429s
09/16/2022, 3:53 PMbdw429s
09/16/2022, 3:54 PMbdw429s
09/16/2022, 3:55 PMdanlance
09/16/2022, 3:55 PMbdw429s
09/16/2022, 3:56 PMbdw429s
09/16/2022, 3:56 PMdanlance
09/16/2022, 3:56 PMbdw429s
09/16/2022, 3:57 PMbdw429s
09/16/2022, 3:59 PMbdw429s
09/16/2022, 3:59 PMbdw429s
09/16/2022, 3:59 PMfusionreactor.serverName
in your server.json
to override the server name in FRbdw429s
09/16/2022, 3:59 PMdanlance
09/16/2022, 4:00 PMdougcain
09/16/2022, 4:51 PMdanlance
09/16/2022, 4:54 PMdanlance
09/16/2022, 4:58 PMbdw429s
09/16/2022, 5:30 PMdanlance
09/16/2022, 5:30 PMbdw429s
09/16/2022, 5:30 PMbdw429s
09/16/2022, 5:31 PMbdw429s
09/16/2022, 5:32 PMbdw429s
09/16/2022, 5:32 PMif( ConfigService.getSetting( 'server.singleServerMode', false ) && getServers().count() ){
return getFirstServer();
}
bdw429s
09/16/2022, 5:33 PMbdw429s
09/16/2022, 5:34 PMdanlance
09/16/2022, 5:43 PMdanlance
09/16/2022, 5:43 PMdanlance
09/20/2022, 7:01 PMdanlance
09/20/2022, 7:04 PMbdw429s
09/20/2022, 7:06 PMbdw429s
09/20/2022, 7:06 PMbdw429s
09/20/2022, 7:07 PMdanlance
09/20/2022, 7:08 PMbdw429s
09/20/2022, 7:09 PMdanlance
09/20/2022, 7:09 PMbdw429s
09/20/2022, 7:09 PMbdw429s
09/20/2022, 7:09 PMdanlance
09/20/2022, 7:10 PMbdw429s
09/20/2022, 7:10 PMAWS_INSTANCE_ID=`curl -s <http://169.254.169.254/latest/meta-data/instance-id>`
bdw429s
09/20/2022, 7:10 PM%{AWS_INSTANCE_ID}
in your server.json
bdw429s
09/20/2022, 7:12 PM${aws-meta.INSTANCE_ID}
that does a HTTP behind the scenes to get the data.bdw429s
09/20/2022, 7:12 PMbdw429s
09/20/2022, 7:12 PMdanlance
09/20/2022, 7:13 PMdanlance
09/20/2022, 7:14 PMbdw429s
09/20/2022, 7:15 PMdanlance
09/20/2022, 7:18 PMbdw429s
09/20/2022, 7:25 PM${foo}
place holder in a CommandBox JSON file, it would first need to be something CommandBox knew how to find.bdw429s
09/20/2022, 7:27 PM${}
construct (called system settings) is much more than env vars. It's
• local CommandBox env vars set in the box CLI
• Java system properties in the CLI's Java process
• OS-level env vars set in the process that is running the CLI/Java
• a series of internal namespaces defined by CommandBox such as ${serverinfo.serverHomeDirectory}
, ${boxjson.name}
or ${@localJSONKey}
• Any custom namespaces you want to define in a custom module you (or someone else) has written that defines a pattern of ${mynamespace.mykey}
and implements the lookup for those valuesdanlance
09/20/2022, 7:28 PMbdw429s
09/20/2022, 7:29 PMbdw429s
09/20/2022, 7:29 PMdanlance
09/20/2022, 7:30 PMbdw429s
09/20/2022, 7:30 PM${custom-aws-secret-namespace.name-of-secret}
so people can use AWS's custom secret store directly in their JSON files via system settings. It would be trivial to write, I just don't need it myself, lolbdw429s
09/20/2022, 7:31 PMdanlance
09/20/2022, 7:31 PMbdw429s
09/20/2022, 7:32 PMbdw429s
09/20/2022, 7:32 PMdanlance
09/20/2022, 7:33 PMdanlance
09/20/2022, 7:33 PMdanlance
09/21/2022, 10:14 AMdanlance
09/21/2022, 10:15 AMdanlance
09/21/2022, 3:36 PMinterceptData.resolved=true;
return true;
I’m just trying to ensure that there’s no risk of this being called repeatedly… and also ensure that if it does not retrieve the instancID (probably as it’s not running on aws) that it does not prevent loading - ideally logging warning to console output.
In the event that we catch an exception with the http call… how should the above 2 values be set?bdw429s
09/21/2022, 5:14 PMlog
logger available in your interceptor
log.error( 'error getting system setting #name#', e )
which will go in CommandBox logs visible with
system-log | tail
In the event of an error, you should return the default value which was provided. The default value should be provided any time you can't find whatever was asked for. You could choose to throw an exception if you are very sure there will not be a default value and it is fatal if nothing is found, but that's not really how system settings works. Default values are provided like so
${namespace.key:default}
danlance
09/21/2022, 5:16 PMbdw429s
09/21/2022, 5:18 PMbdw429s
09/21/2022, 5:18 PMdanlance
09/21/2022, 5:18 PMbdw429s
09/21/2022, 5:18 PMdanlance
09/21/2022, 5:20 PMbdw429s
09/21/2022, 5:21 PMbdw429s
09/21/2022, 5:21 PMbdw429s
09/21/2022, 5:21 PMbdw429s
09/21/2022, 5:22 PMenv show aws.foobar
or this
echo ${aws.foobar}
it will fire the system setting expansion interception point, which allows any interceptor (including the core one) to resolve the valuedanlance
09/21/2022, 5:22 PMbdw429s
09/21/2022, 5:22 PMdanlance
09/21/2022, 5:23 PMdanlance
09/21/2022, 5:23 PMbdw429s
09/21/2022, 5:23 PMbdw429s
09/21/2022, 5:24 PMbdw429s
09/21/2022, 5:24 PMsystemOutput( 'I was called...', true )
bdw429s
09/21/2022, 5:25 PMdanlance
09/21/2022, 5:26 PMbdw429s
09/21/2022, 5:26 PMbdw429s
09/21/2022, 5:26 PMdanlance
09/21/2022, 5:26 PMdanlance
09/21/2022, 5:27 PMdanlance
09/21/2022, 5:27 PMbdw429s
09/21/2022, 5:27 PMbdw429s
09/21/2022, 5:28 PMModuleConfig.cfc
, but then you don't get all the fun framework super type stuffbdw429s
09/21/2022, 5:28 PMdanlance
09/21/2022, 5:28 PMbdw429s
09/21/2022, 5:29 PMbdw429s
09/21/2022, 5:29 PMServerSystemSettingExpansions
interceptorbdw429s
09/21/2022, 5:30 PMdanlance
09/21/2022, 5:30 PMbdw429s
09/21/2022, 5:30 PMserverjson.
and serverinfo.
)danlance
09/21/2022, 5:32 PMbdw429s
09/21/2022, 5:32 PMdanlance
09/21/2022, 5:33 PMbdw429s
09/21/2022, 5:33 PMbdw429s
09/21/2022, 5:34 PMModuleConfig.cfc
is also registered as an interceptor) is quick and dirty, but the method doesn't have access to the useful interceptor base class variables like logbox. Doesn't mean you can't get it-- it's just a bit more boilerplate again.danlance
09/21/2022, 5:35 PMbdw429s
09/21/2022, 5:36 PMbdw429s
09/21/2022, 5:37 PMis it there by default,Yeah, there's a ton of stuff just already there. Interceptors are like COldBox handlers in that they use Wirebox's virtual inheritance to extend a special base class at run time
bdw429s
09/21/2022, 5:37 PMdanlance
09/21/2022, 5:37 PMbdw429s
09/21/2022, 5:38 PMbdw429s
09/21/2022, 5:38 PMbdw429s
09/21/2022, 5:38 PMlog.error( 'message' );
bdw429s
09/21/2022, 5:38 PMdanlance
09/21/2022, 5:38 PMbdw429s
09/21/2022, 5:40 PMbdw429s
09/21/2022, 5:41 PMbdw429s
09/21/2022, 5:42 PMdanlance
09/21/2022, 6:28 PMdanlance
09/27/2022, 12:42 PM/usr/local/lib/CommandBox/cfml/modules/
in docker build process… which works fine.
I’ve attempted to turn into a package using box init command, which created a box.json file.
I then commited the module folder to github public repo, and am attempting to install as I do with other packages within Dockerfile, but from git endpoint:
RUN box install git+<https://github.com/Gencia/commandbox-awsimds.git>
This appears to work - as in I see the following within the docker build output:
#9 [5/7] RUN box install git+<https://github.com/Gencia/commandbox-awsimds.git>
#9 11.24 √ | Installing package [git+<https://github.com/Gencia/commandbox-awsimds.git>]
#9 DONE 11.8s
However, when I start the container, I cannot see the module within the modules folder, and also no log entry in the logbox log (which I would expect when running in local environment)
I’m sure theres some basic step I’ve missed here.. but struggling to see why it’s not working…
Are you able to shed any light on this?bdw429s
09/27/2022, 2:59 PMbox.json
https://github.com/Gencia/commandbox-awsimds/blob/master/box.json#L56bdw429s
09/27/2022, 2:59 PMcommandbox-modules
which would have been obvious if you just tested with the install --verbose
commandbdw429s
09/27/2022, 2:59 PMbdw429s
09/27/2022, 3:00 PMbdw429s
09/27/2022, 3:01 PMlink
command which creates a nice symlink for you to the commandbox system folder so you don't need to go copying stuff around and having more than one copy of the code
https://commandbox.ortusbooks.com/developing-for-commandbox/modules/linking-modulesbdw429s
09/27/2022, 3:01 PMbdw429s
09/27/2022, 3:02 PMpublish
from the root of the package and then the installation just becomes
install commandbox-awsimds
bdw429s
09/27/2022, 3:03 PMbdw429s
09/27/2022, 3:04 PMdanlance
09/27/2022, 3:06 PMdanlance
09/27/2022, 3:10 PMdanlance
09/27/2022, 3:11 PMdanlance
09/27/2022, 3:24 PMdanlance
09/27/2022, 3:26 PMbdw429s
09/27/2022, 3:42 PMbdw429s
09/27/2022, 3:42 PMbdw429s
09/27/2022, 3:43 PMserver start
danlance
09/27/2022, 3:45 PMbdw429s
09/27/2022, 3:47 PMmake it easy to get dev environments up remotely for external contractors etc. in a consistent manner which is mostly independent of the system being used… and be much more confident that something that works locally will work within hosted environments subject to consistent configuration….☝️ ☝️ ☝️ ☝️ ☝️ ☝️
bdw429s
09/27/2022, 3:47 PMgit clone ...
box install
box server start
bdw429s
09/27/2022, 3:49 PMbdw429s
09/27/2022, 3:49 PMdanlance
09/27/2022, 4:02 PMbdw429s
09/27/2022, 4:16 PMthere would be more difference between the local and prod environments with that approachI actually think it's far fewer differences than people realize. The JVM itself already provides a abstraction layer, and CommandBox is capable of dialing in the exact version of your CF engine, and even your JDK version. If I were to draw a Venn diagram of all the configuration things that could make a difference between dev and prod, there would be a huge circle of things and then an ever-so-slightly-smaller circle inside labeled "stuff CommandBox lets you control" 🙂 Heck, CommandBox even lets you force the case sensitivity (or lack thereof) for static files in the web server so you can be on Windows and pretend it's Linux or vice versa!
relies on nginx etc. for URL rewriting, S3 proxying and client cert based authenticationCommandBox already does • URL rewriting • client cert auth (new in the latest version!) I'm not sure what you mean by S3 proxying, but I'm curious, since Undertow's built in HTTP proxy can probably do it too!
bdw429s
09/27/2022, 4:17 PMserver.json
, box.json
, and .cfconfig.json
but just without the complexities of Docker wrapping it.danlance
09/27/2022, 4:19 PMbdw429s
09/27/2022, 4:19 PMbdw429s
09/27/2022, 4:20 PMpath-prefix('/reports') -> reverse-proxy({'<http://reports1.mydomain.com>','<http://reports2.mydomain.com>'})
danlance
09/27/2022, 4:20 PMbdw429s
09/27/2022, 4:20 PMbdw429s
09/27/2022, 4:21 PMbdw429s
09/27/2022, 4:22 PMbdw429s
09/27/2022, 4:23 PMbdw429s
09/27/2022, 4:25 PMdanlance
09/27/2022, 4:26 PMdanlance
09/27/2022, 4:27 PMdanlance
10/04/2022, 11:19 AMbdw429s
10/04/2022, 5:52 PM