First time User...finally

Well with thanks to Brad or perhaps it’s; “Let’s blame Brad!”… I am trying to start with ColdBox…

I have read the docs and did a search in here, too - and I can’t for the life of me, find the answer…

How do I use Coldbox’s embedded server with an existing application?

Can I use the embedded Server?
Do I need a separate install of Lucee?
Where is the server Home - so I can set config items?

I am imagining my use of ColdBox to be… host-specific “native” containerisation of my apps…

Run a ColdBox instance for Application “A”.
Run a second ColdBox instance for Application “B”
Use CFConfig for both…

Is this an appropriate use-case? Or am I barking up the wrong tree?

Thanks very much!
Gavin.

Hi @GavinBaumanis

You don’t need to install Lucee, because CommandBox will do everything(!!!) for you:After installing CommandBox, just open a terminal session, change into your wwwroot, and type box server start. Then lay back, watch the console and you’ll see CommandBox in action. It will do all the rest: It will download the latest Lucee version and start running Lucee with its own embedded server undertow (instead of Tomcat).

What is sometimes a little confusing for newcomers is, that running Lucee with CommandBox is so freaky simple!!! You just need to install CommandBox, open the terminal session and run it with box server start.

To make things even simpler, you can add all your settings (even URLrewrites!!!) into a server.json file and put it into your wwwroot. Commandbox will run Lucee and the embedded server with all those settings.

1 Like

I am not sure what I was doing when I wrote the topic.
In that I started it in the webroot - and it works like a charm - of course…

I “thought” that’s what I was doing - before I posted…
Anyway - All working as advertised!

Thanks!

And just to add here, ColdBox is an MVC framework you use in your code to help write web apps and REST APIs. CommandBox is a CLI that starts servers. And while these tools work very well together, they do not require each other and are totally separate things.

Depends on what you mean when you say “server home”. if you just want to access the Lucee admin UI, you can use the menu in your system tray for the server and you’ll find a link under the “open” submenu. If you mean the actual folder on disk where Lucee’s files are-- every server you start in CommandBox has a separate server home and you can actually find it in the same place of the tray menu I mentioned above.

image

Assuming you meant “CommandBox CLI” and not “ColdBox”, then yes that is a perfectly reasonable use-case. Really, no matter how many apps you have, generally each project folder (which is likely also your Git repo) has

  • the code
  • the server.json
  • the .cfconfig.json
  • Maybe even a box.json for your dependencies (ColdBox would go here :wink: )

and then each project root is a completely stand-alone project and you can simply cd into that folder and run server start, server stop, server log --follow, etc, etc to interact with that server.

Hi Everyone,

You’re absolutely right… I mistyped… I am starting off my use of CommandBox!
Thanks very much for your time with replying, Brad - I really appreciate it.

I got “thrown” by two things…
I “thought” I started box in the “approot” - but obviously didn’t.
And;
When I first started box I configured an Admin password - but got prompted for importing one…
So I “thought” (again) that there was something amiss with how I was running it…
I didn’t realise that setting the password on start - didn’t do the import automatically for you…

So once I started in the correct directory and imported the password.txt (which was created by box) - everything was exactly as advertised.

I was initially determined to “replicate”, as close as possible, our production servers on my local machine and was adamant that I was going to do “something other” than CommandBox - since we don’t use it in production…

I have come to realise that was just “stubbornness” and I, sincerely, thank everyone involved with CommandBox for the work that has been put into it - and making it available for free, too.
I am really impressed it, by it as a solution and CFConfig is really awesome, too and my personal “driver” for using CommandBox, locally.

Again thanks to everyone - I feel like a converted cult member!

Gavin.

1 Like

It can always be useful to look at commands like

server list

which will show all the servers you’ve ever started, what folder their in, what CF engine their on, what ports they are listening to, etc, etc to help notice if you have an errant server running in the wrong place.

Also, installing bullet train will give you SO MUCH extra information about the current directory you’re in on your server that it’s nearly impossible to get confused about where you are.

Just cd'ing into a directory will intsantly tell you

  • what folder you’re in
  • the name and version of the project in that folder (read from box.json)
  • The Engine and running/stopped status of any server in that folder
  • The branch and status of any Git repo in that folder
  • etc

Just to be clear, CFConfig doesn’t ever create a password.txt file. It hashes the plaintext password and stores it directly in the XML config files for Lucee. The password.txt file is really only something that people unfortunate enough to not be using CFConfig must deal with.

Mission Accomplished :sunglasses:

Hi again,

From a documentation perspective I still think you need something like;
(obviously my wording is "pseudo-documentation!!)

Upon initial use of a new server, even if you have used, cfconfig set adminPassword=XXXX, you will get prompted to import the password… this is cool and normal : go ahead and use the import button!

That is an awesome tool!
Reminds of the “shit” is used try and cram into a Unix shell prompt!
But in a much prettier layout!

This makes no sense at all and I would never recommend people try and use that horrible password.txt file. Can you perhaps document exactly what you’re doing that isn’t working for you, because I start fresh Lucee servers all the time and I’ve never needed to use the password.txt file.

It almost makes it sound above like you are

  • creating an empty folder with no server at all
  • randomly running a cfconfig set command on… thin air?
  • Then starting a server

That obviously wouldn’t work because there needs to be a server in existence in order to set its password! You can, of course, set the password after the server has started, but unless you’ve configured Lucee to watch the XML files on disk for changes, you’d need to restart Lucee to pick up this change.

Then you have the option of having your password (either hashed, or plain text, your choice) in your .cfconfig.json file in the web root, which will be loaded automatically when the server starts.

And finally, you can set an env var, either a one-off like so:

set cfconfig_adminPassword=mypass
server start

and CFConfig will detect and import it. Or my favoriate method which is to set a global env var as a one-time thing which is always present in my CLI and auto-imports into every server I ever start.

# one time setup
install commandbox-dotenv
propertyFile set ~/.box.env cfconfig_adminPassword password

# applies now and to forever
server start

You really haven’t been clear about what you’re doing so it’s hard to say why it isn’t working for you, but there are many better ways to get a password set with little effort and none of them involve that password.txt file :wink:

So - I have worked it out why I was experiencing the password import prompt - and it all makes perfect sense.

// new coldbox server
server start
cfconfig set adminPassword=NewPassword

// go to Lucee Admin without restarting server
// get the IMPORT PASSWORD prompt

I suppose I was expecting “magic” to happen here - in that;
I just set the password - It SHOULD be part of the current server’s running config.

Alternatively;
// new coldbox server
cfconfig set adminPassword=NewPassword
server start

//Works exactly as I thought the first would - of course!

Gavin.

Yeah, Lucee reads the XML files on startup and form then on out it uses the config that’s stored in memory. So if the XML files change on disk, Lucee isn’t looking at them unless you’ve told it to.

Note, this still requires that the server has been started at least once since you can’t set config into a server that doesn’t exist (well, not like that anyway). Which is why I recommend the global .env file approach.

1 Like