Is it possible to have a CommandBox server with a ...
# box-products
b
Is it possible to have a CommandBox server with a name derived not from the current folder but from a parent? Let's say I have this folder structure and server.json lives inside the "app" folder, I'd always wind up with servers called "app" and it's not clear which I'm starting and where it lives:
Copy code
websites
  <http://website1.com|website1.com>
    app
  <http://website2.com|website2.com>
    app
I've also tried
server start name=<http://website2.com|website2.com>
from the "app" folder there but it fails to find server.json, which makes sense because that's how the docs say it will work
I do not have a .env file inside "app" that gives it a specific name, though that would be one possible solution.
t
the
name
element in server.json, and use an env var to set it something like
{ "name": "${SITE_NAME} }
b
Is it possible to have a CommandBox server with a name derived not from the current folder but from a parent?
@bockensm Yes, write a custom module that listens to the
preServerStart
interception point and manually overrides the
interceptData.serverDetails.defaultName
to override the default name on first server start.
That said, the better option is just to set the name in your
server.json
or pass it in your
server start
command. Just keep in mind, a server's name is immutable once the server starts at least once, so trying to change it after the fact will probably just create a duplicate server. Make sure you have the name specified from the very first start
tried 
server start name=<http://website2.com|website2.com>
 from the "app" folder there but it fails to find server.json
To be clear, this should still work. I just tested with these commands and it names the server as I requested AND uses my
server.json
file
Copy code
mkdir servernametest --cd
server set web.HTTP.port=1234
start name=nametestfoobar serverConfigFile=server.json --verbose
Setting the
name
property inside your
server.json
will also work too
Copy code
server set name=nametestfoobar
server start --verbose
cc/ @thisOldDave
b
Ah, I didn't pass
serverConfigFile
so that's why it didn't find the config
The interception point option sounds interesting