Hi all, is there a recommended way to use a debugg...
# cfml-general
b
Hi all, is there a recommended way to use a debugger to step through a .cfm file? For example using vs code if possible? I'd like to place a breakpoint somewhere and step through what happens in the code, currently I'm just using a dump to check variables etc , but it's tedious
b
Depends on your CF engine
• BoxLang has a debugger in our VSCode extension (but I doubt that's what you're using) • I'm 99% sure Adobe has a debugger in their VSCode extension, but I've not used it. • Lucee doesn't have an official one, but there is a pretty good one made by David Rogers (software cobbler on Github)
b
Got it. I'm using Lucee v6. So I'll look into David's debugger. Thanks
šŸ‘ 1
j
There is also a vscode extension for the lucee debugger that I have heard good things about. https://marketplace.visualstudio.com/items?itemName=DavidRogers.luceedebug
šŸ‘€ 1
b
That's the one I was referring to, no?
j
Yes you are correct. I thought they were packaged separately. That doesn't seem to be the case though.
šŸ‘ 1
b
Nice. Well at least I don't have to try out a bunch to decide what to use šŸ˜†
b
On a separate, but related note-- to tag on to the other thread you had the other day about just getting running with CF. I noticed you're using Docker, which is great if you really love Docker. I just wanted to point out CommandBox itself is a full fledged web server as well and can provide you with 95% the same level of isolation just running directly on your host machine without the additional layers and complexity of docker if you wish.
For example, at Ortus we use Docker Swarm for all our stage and prod deploys and love it, but the majority of our dev setups, are just straight CommandBox which offers a lot of simplicity with minimal install requirements for the team
Since your entire site and config can basically be contained in 3 JSON files •
box.json
- pacakge descriptor •
server.json
- server config •
.cfconfig.json
- ColdFusion config (like datasources) you get pretty good portablity anywhere with just
Copy code
git clone...
box install
box server start
b
This is good to know and thank you. The app I'm working on was not built by me and was built years ago, so I'm trying to figure out how to work with what is there currently. I'm going to have a lot of questions being new to CFML but this slack has been awesome for finding things out
šŸ‘ 2
I can also bring suggestions I learn here to stakeholders as well
b
Well, if they're using CommandBox they can't be too far off šŸ˜‰ (I'm the lead developer of CommandBox)
b
Awesome. The resources and people here are going to be an invaluable resource šŸ™
b
The first one's free. 2 more answers and I'll stop half way through and you have to put in a quarter to get the rest of the answer šŸ¤– šŸ˜†
šŸ˜… 1
j
I was recently reminder that FusionReactor also has a debugger : https://www.fusion-reactor.com/production-debugger/
b
Oh yes, good call. It's not integrated into your IDE like the others. FR used to have FusionDebug which did this, but they stopped supported it. Their "production debugger" is a web based debugger that uses a java agent.
b
Cool will check this out, thank you
I'm trying to setup luceedebug and installed the extension into vs code, however there are additional instructions to add a .jar (I downloaded it) and configure an agent. With little java background I have no idea what this means and am not finding help searching online. The instructions on the luceedebug GitHub page say to add some lines/commands (or flags?) to your java invocation. What and where would the java invocation be in a docker containerized Lucee app? (The lines to be added are shown in the repo readme as -agentlib:... And -javaagent:...)
b
Do you simply need the jar to be in the classpath, or do you need to add a JVM arg?
Someone should make a CommandBox module for this to make it simpler šŸ™‚
ā¤ļø 1
Use
app.libDirs
in your
server.json
to add it to the classpath
Use
jvm.args
(array) to add JVM args to the server start command
And, of course, the jar will need mapped inside the docker container in either case
b
I downloaded the jar from the luceedebug link, so I got that far. I can add a bind mount to map the jar to the container as well. I'm just not sure what configuring the agent and java invocation means or where that is. I do see server.json so I'll add your suggestions there and give it a whirl.
b
Glancing at the docs, I assume you'd want something like this in your
server.json
Copy code
{
  "jvm": {
    "args": [
      "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999",
      "-javaagent:/abspath/to/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/abspath/to/luceedebug.jar"
    ]
  }
}
Replacing the
/abspath/to/luceedebug.jar
of course with the real path inside the container
b
Yeah that was my guess too, thank you. Going to plug this in and try it
b
The other issue you're going to have is ports
One of the many reason EVERYTHING is more complicated when Docker is involved
b
Right port for the app is localhost:80
b
You'll have to find and expose all the ports
no
the debugger has its own ports
b
Ah
b
See the
9999
above and the port
10000
šŸ‘€ 1
All that is used for the VSCode extension to communicate with the Java process
Outsdie of docker, it prolly all "just works", but you'll have to expose and map all that stuff through the container
b
I see, great call out. I'll get those ports exposed in docker-compose as well
šŸ‘ 1
Oof, almost worked. I get an exception when running docker compose up stating that the .jar file is class 55 and the java version we're using only allows for class 52. Googling this I learned this means that I can't use this jar with java jre v8, but i don't want to mess with updating the jre version in the app. Unless I can track down a class 52 version of the luceedebug .jar file, I guess it's back to cfdump for now
b
If you're still using Java 8, that is an oof šŸ™‚
Your shop needs to get off that
Ping David Rogers and ask him, but hey may only sport Java 11 (which is number 55) and up
b
Understood. I'll ask about the lift to upgrade from java 8 in the meantime. Ty šŸ™
šŸ‘ 1
b
It's gotten REAL hard to be on Java 8 these days
A lot of libraries out there have left it behind
And sometimes in minor updates of their lib too 😠
b
I see and that makes sense. we're going to need to be prepared to upgrade sooner or later so might as well bite the bullet.