Question about commandbox embedded server developm...
# box-products
r
Question about commandbox embedded server development: I'm porting my dev environment over to a Mac from Win10. I want to use commandbox as my runtime environment, which I have more or less setup. Currently, I can access the site and the Lucee admin, and I'm questioning my next steps. I would like to be as portable as possible and avoid having to manually enter a bunch of stuff in the lucee admin, like caches, datasources, email, etc. I assume I'll use cfconfig, but I'm wondering if I should first manually enter all the lucee stuff in the lucee admin, and then use cfconfig to export that information into a file that can be reused. Or is there a better way to approach this?
b
@redtopia That's one way to do it, but why not just export your previous settings from the old server?
r
from my windows machine?
b
yeah
We generally commit our
.cfconfig.json
file to the root of the project so it's just there with the source code. Then we replace any sensitive or env-specific bits with environment variables.
r
ok... and then how do I get those settings into my commandbox instance? Do I use cfconfig?
b
Yes
r
just the first time after I run the new instance?
b
Just having CFConfig installed will pick up the
.cfconfig.json
file by convention every time the server starts
r
oh okay
b
Run
coldbox create app
in an empty folder if you want to see how we usually set it up
That will create a skeleton coldbox app with all these files (
.cfonfig.json
,
.env
,
.env.example
, etc)
r
so right now, I have server.json sitting out at the root of my app... you're saying create a .config.json file in the root as well, and then whenever commandbox runs, it will use that .cfconfig.json file?
āœ… 1
So, for starters, just go to your old Windows folder and run
Copy code
cfconfig export .cfconfig.json
and there's your JSON file full of settings.
r
ok... but a lot of those settings I might move to the web context. I currently have them in my server context because I am not currently using commandbox on windows
b
And if you want to be really lazy, you can even have CFConfig put in the env var replacements and create the
.env
file for you https://cfconfig.ortusbooks.com/using-the-cli/command-overview/export-settings#json-expansion-replacements
r
I assume I should be putting all my settings in the web context?
b
I don't see what windows has to do with whether you use the web or server context.
r
if I put them in the server context, is that still isolated from other commandbox embedded server instances?
b
I see no reason to ever use the web context for anything unless • you're using ModCFML and have more than one of them • you're storing scheduled tasks
if I put them in the server context, is that still isolated from other commandbox embedded server instances?
Yes, of course! Every CommandBox server is 100% totally separate from every other server
r
okay... that's good to know. I wasn't sure about that... I thought that maybe the server context was global
b
r
Thanks Brad... this is helpful
@bdw429s I'm in my www folder and tried running
Copy code
cfconfig export .cfconfig.json
and got an error "we couldn't find your [from] server. Do I need to be in the
WEB-INF
folder when I run it?
or do I specify the path to the c:/lucee
b
@redtopia There's not enough information for me to answer this question. is the Windows server a CommandBox server?
I've assumed it was this whole time, but your last couple messages make me question that assumption
r
yea, windows... I figured it out. I specified from=c:/lucee/tomcat/lucee-server and it seems to have worked
b
You keep saying "windows" as though it has some bearing on how Lucee is installed. But it doesn't šŸ¤”
r
is there a way to modify tomcat settings? I've made a few changes to allow me to upload huge files, and I also had to make a change to enable websockets.
b
I'm assuming the old server was not a CommandBox server, and was just a traditional Tomcat-based Lucee instance where you used the installater.
r
yes, correct
b
is there a way to modify tomcat settings?
In CommandBox? CommandBox doesn't use Tomcat.
r
ok... makes sense. Is there a way to modify the settings of the server to enable large file uploads and websockets, and that sort of thing?
I have read through the docs on settings.json, and I can see how to do things like setting up urlrewrites
b
We use JBoss Undertow and their correlating setting appears to be https://undertow.io/javadoc/2.0.x/io/undertow/UndertowOptions.html#MAX_ENTITY_SIZE
I've never mapped a CommandBox "proper" setting for that, but you can set any arbitrary settings in the
server.json
as documented here https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/undertow-options#undertow-options
r
Thanks Brad
b
Undertow also has a
MULTIPART_MAX_ENTITY_SIZE
setting which may or may not apply based on your form type
So I'd try something like
Copy code
server set runwar.undertowOptions.MAX_ENTITY_SIZE=9999
I'm trying to figure out what the "size" is in-- Undertow is rather lazy about putting that sort of thing in the docs eye roll It's probably bytes
Regarding Websockets, I'm not sure what you added in Tomcat for that so I'm not sure what the Undertow equivalent is. We do include the Undertow Websocket jar, but I don't know if that's the same as what you added in Tomcat.
On a related note, I just noticed Undertow's
DEFAULT_MAX_ENTITY_SIZE
has this note in the javadocs
We do not have a default upload limit
So you may not need to set anything. I'd test first and see if CommandBox will just work out of the box for you.
And in related news, I just bugged the Undertow peeps about their poor docs https://issues.redhat.com/browse/UNDERTOW-2193
šŸ‘šŸ¾ 1
r
lol thanks Brad