box server restart failing

When I try to restart my box server, I get the error below. My server stays running and I don’t think it ever shuts down. Currently I stop/start to handle this, but this changes my port (I need to see if I can use one particular port).

Trying to stop server…

server stop ‘crud’
Stopping crud…
lucee.commons.cli.CommandException: Could not stop server. Are you sure it is running, and listing for stop requests on port 58389?

at lucee.commons.cli.Command.execute(Command.java:69)
at lucee.runtime.tag._Execute._run(_Execute.java:81)
at lucee.runtime.tag._Execute.run(_Execute.java:72)
ERROR
Error invoking external processCould not stop server. Are you sure it is running, and listing for stop requests on port 58389?

Trying to start server…

server start name=‘crud’ port=58388 openBrowser=false --!saveSettings
The server for /Users/raymondcamden/OneDrive/WorkProjects/md/crud is starting on 127.0.0.1:58388… type ‘server status’ to see result
lucee.commons.cli.CommandException: objc[22086]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/bin/java (0x10af9e4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10b0e84e0). One of the two will be used. Which one is undefined.

Ray,

It’s probably because of this argument in your server startup:

--!saveSettings

Because the settings of the server aren’t being saved, the restart command doesn’t know which port and, subsequently, the stop port to use.

HTH,

Jon

Jon Clausen

Silo Web, LLC
P: (616) 350–6658

Ok, how did that argument get used? I didn't add it.

I *have* added a port now:

        "http":{
            "port":8080
        }

But restart gives the same error.

Actually, it is a bit worse now. :wink: Restart keeps my 8080 server up
and starts a new one on a random port.

The port syntax for server.json should be

"web":{
        "http":{
            "port":"8080"
        }
    }

Is that what you have?

Yep. To be clear, if I start it, it works fine. Uses the right port.
It's restart that is causing the issue.

Specifically - still this:

server stop 'crud'

Stopping crud...
lucee.commons.cli.CommandException: Could not stop server. Are you
sure it is running, and listing for stop requests on port 58389?

Do I need to specify a port for 'commands'?

What about when you specify the name argument explicitly:

server restart name=crud

I can’t remember the argument order for the server start, but I always specify the name argument when use stop/restart

BTW, the server.json file you’re working with is the one named server-crud.json, correct?

If you specify a name for a server, that is the file that will be used for the config. server.json is only applicable when a name argument is omitted.

Just wanted to make sure.

If you want to see some server-[name].json examples, you can look at this repo here: GitHub - jclausen/cbox-i18n: The module that provides i18n and localization features for any ColdBox application

I’m updating the Travis build for that module to use all of the Commandbox engines, as we speak. So, for example, for Lucee5, I can use:

server start name=lucee5

server restart name=lucee5

server stop name=lucee5

And so on and so forth with all of the engines.

No, it is server.json. I've not "named" this server. How do I do that?
box server name X didn't work. Can I just literally rename server.json
to server-X.json?

Ok.... so I renamed server.json to server-mdcrud.json.

Now I can

box server start name=mdcrud

and

box server restart name=mdcrud

I wish I could specify a default name for the current directory so I
didn't have to add name=X, but restart works now. Of course, I have to
re-add my DSN. I need to add that to my App.cfc.

You don’t have to use the name argument if you are only going to be starting/stopping one server. The command generated for the server start in the restart command (earlier in the thread) was

server start name='crud' […etc]

which is being called because the server name argument is passed in your restart command:

server restart 'crud'

This “names” the server and will automatically look for a file named server-crud.json, which will be the core config for that server. From that point on, the name argument will have to be passed to all of the sever commands for that server, or it will use the default (creating it, if it doesn’t exist).

Omitting the name argument will default to using the default server.json file.

Unless you’re doing multi-engine work/tests, you likely only ever need a single server.json file. If there is a name key in your core server.json, then remove it and just use server start, server restart, etc.

If you want to use a specific engine with your default server, you can just configure it in the base server.json file:

"app":{
        "cfengine":"lucee@5"
    },

HTH,

Jon

I'm not quite sure I understand what you are saying. In every case
when I left off name, box wasn't able to restart. I can say I've got
multiple servers with the name 'crud' in my core servers.json, and
maybe box was confused?

That’s probably exactly what’s happening. There can be only one server config per server.json file.

There was a beta version of 3.0 that used a single config file, but that created all sorts of problems and was dropped in favor of multiple server config files.

If you have named servers in the default server.json file, that may be at issue as well.

I think I'll leave stuff alone for now and just deal w/ the name=x. As
it stands, I probably won't be stopping very often, just restarting to
get rewrite rules updated. :slight_smile:

I’d have to look up how to do it, but FWIW, there’s a setting that will automatically reload the rewrite config so you don’t have to keep restarting.

I think it might be debug=true but I might be mistaken-- both on the argument name and the possibility of even doing it. :slight_smile: