and a .custom.env file used in server.json in dotenvFile key
server.name = test-dotenv
server.port = 6062
server.profile = development
if I start the server the CLI remains blocked starting the server…
I have to kill the terminal.
It doesn’t happen if I remove the “dotenvFile” key and use the default env file name (“.env”)
OR
if I had previously started a server inside this folder (without specifying “dotenvFile” in server.json).
The CLI gets freeze, it doesn’t install any servers inside $user/.CommandBox/server
and I can’t find any log files to understand the error.
There is nothing significant in $user/.CommandBox/logs/commandbox.log.
I assume you have ripped a hole in the fabric of the space time continuum by creating an endless loop. It always gets very tricky when you try to use information stored in the server.json to affect the values of the server.json itself due to the chicken-egg problems.
Glancing at the dotenv code, I don’t see the issue right off, but you can get a stack trace of what the CLI is doing with the jstack -l <pid> command (jstack comes with a JDK). You can also tie FusionReactor to the CLI to monitor what’s happening.
Yes, the dot env file can be a comma-delimited list of file globbing patterns. It would seem you’ve hit some sort of endless loop inside of the Globber library actually. I’d have to see what the actual file path was that’s being processed.
Also note, any server default dotenvfile settings will be added into the mix. It doesn’t appear that there is any logging in the dotenv module that shows the paths pre-globbing.
So in theory, .custom.env in the server.json should turn into /absolute/path/to/webroot/.custom.env which should be pretty cut and dried and wouldn’t be any different than running the following command in CommandBox:
dir /absolute/path/to/webroot/.custom.env
To debug, I’d dump out the serverEnvFile variable to the screen prior to this line
I replicated the same function from line 56, step by step:
addLog("serverEnvFile: [#serverEnvFile#]");
//result: [\\.custom.env]
//I tried to remove the double slashes but the problem persists.
//add pattern to Globber...
variables.wirebox.getInstance("Globber").setPattern(serverEnvFile);
//get pattern just entered
addLog('getPattern: [#variables.wirebox.getInstance("Globber").getPattern()#]');
//result: [] (yes, empty)
addLog('matches: #SerializeJSON(variables.wirebox.getInstance("Globber").matches())#');
//this get an error: "Cannot glob empty patter eith no base directory"
//restart with original code from here:
variables.wirebox.getInstance( "Globber" )
It seems the problem is that it can’t set the pattern.
I also tried to set the absolute path of the file by hand before: variables.wirebox.getInstance( "Globber" )
like this: serverEnvFile = "/absolute/myhost/code/.custom.env ";
I’m not quite sure what you are trying to do with your test code, but every time you run getInstance(), you are getting a brand new fresh Globber instance as it is not a singleton. This is why it appear you cannot set the pattern as you are looking for it in a totally separate CFC instance than the one you set it into.
However, serverEnvFile should contain the absolute path.
Right?
Perhaps the problem is in line 48: serverJSON.dotenvFile.listMap ((f) => variables.fileSystemUtil.resolvePath (f, getDirectoryFromPath (serverInfo.serverConfigFile)))
This comes back: \\. custom.env
and not the absolute path of the .env file.