How to debug node / express? - eclipse

When I start my app using 'npm start' at the command line I can browse it at :3000
.. but not when I start it using 'node app.js'
when I try 'node --debug app.js' I get a console window with the message
"Debugger listening on port 5858"
With Visual Studio and the node toolkit I get the same. With Eclipse and Enide I get the same.
I've tried using Nodes built in command line debugger, but after the debug> prompt appears issuing the continue or next step commands does nothing, and I can't browse the app at :3000
I've installed node-inspector, and after 'node --debug app.js' I can see app.js in the node-inspector chrome tab :8080, but can't browse my app at :3000 and can't get breakpoints to work.
I guess that to get debugging working I need 'node app.js' to run, and not be using 'npm start'..
What important node configuration detail have I missed?
Why is my app not browsable when using 'node app.js' ?
Any advice is appreciated..

Your actually starting the app in two differnet ways using different code - one which includes the debugger and one that does not.
If your running a default Express 4 setup, if you check the package.json file you will see this section:
"scripts": {
"start": "node ./bin/www"
}
That is the file that is executed when you run npm start, so running node app.js is actually a different script.
If you take a look at bin/www you will see the debugger is invoked:
var debug = require('debug')('myapp');
To run use:
DEBUG=myapp ./bin/www
If you are starting using NPM, you can add it to the package.json or use exactly the same command from the cmd line:
"scripts": {
"start": "DEBUG=myapp node ./bin/www"
}

Related

"Remote kubernetes server unreachable" error in WSL/Ubuntu but not Command Prompt?

So right now I am using Rancher Desktop to run Kubernetes and I keep getting an error in WSL saying "Remote kubernetes server unreachable". The kubectl commands also take a long time to respond. However when I tried to run the same commands in Windows Command Prompt, the responses are quick and I don't get the same "server unreachable" error.
I went ahead and ran "kubectl config view" on both terminals and this is what I found.
Command Prompt: https://imgur.com/a/vCww6yB
WSL: https://imgur.com/a/BnjcW0v
(sorry for the imgur links, they wouldn't let me post images)
Also, I only have one context (rancher-desktop) and I made sure both terminals were set to that.

VS2019 Docker Launch Settings Missing "Start Debugging" action

VS2019 Professional is missing the "Start Debugging" action item which is preventing me from debugging within my docker container.
I have created a launchSettings.json file to explicitly set the StartDebugging action, but still it is omitted from the profile and the debugger does not get attached when attempting to run in debug mode.
{
"profiles": {
"Docker Compose": {
"commandName": "DockerCompose",
"serviceActions": {
"data": "StartDebugging",
"api": "StartDebugging",
"graphql": "StartDebugging",
"kafka": "StartWithoutDebugging"
},
"commandVersion": "1.0"
}
}
}
Another member on the team has the same IDE version as I do, but has no issues having the debugger attached when running in debug mode. We have compared our VS2019 installations and confirmed that we have same workloads installed as well, yet his has the option.
Why would the "Start Debugging" action be missing and how do I bring it back?
I was having the same problem and saw this thread: docker compose doesn't work debugging. The workaround worked for me: disable Docker-Compose V2 support by running docker-compose disable-v2 and then restart Docker Desktop. This is apparently caused by the recent change in docker compose v2 behavior; see Output of "docker compose config" does not contain full path to context

Error encountered in starting Kafka zookeeper application start script

I am seeing an error when I am starting Zookeeper service on windows using command prompt in admin mode. Can somebody assist with this error.
Running the following command in the bin folder:
zookeeper-server-start.sh config/zookeeper.properties
Results in the below error:
"this file does not have an app associated with it for performing this
action . Please install an app or, if one is already installed ,
create an association in the default apps settings page"
You must use zookeeper-server-start.bat on Windows.

WebStorm - run default configuration after starting the `Mongod` tool?

Currently I have a tool setup that will launch Mongod, following the advice of this post.
However, the issue is that when I have my configuration setup to run this Mongod tool before launching, it won't run my node script since there's no "successful completion" by Mongod.
Is there any way around this? In other words, can I have mongod start alongside my configuration but not block my script from running until it "completes"?

Ansible return status

I have an ansible playbook which deploys a jboss eap instance alongside some other things. The playbook runs fine until it gets to the point to start jboss using the provided standalone.sh script. I am using the shell module to start this script and it works fine in that jboss starts however when the task is executed ansible does not return any status message like a changed or OK and just seems to hang.
Is there a way I can force ansible to see this as something which has changed the system state ?
I don't personally use jboss, but this sounds to me like the startup.sh script simply isn't launching jboss in the background, so ansible is simply waiting for it to end and it never does.
There are a few potential ways you can address this. Given the information in this thread you might want to try a task like this:
- name: start jboss
shell: nohup standalone.sh > /dev/null
async: True
poll: 0
The poll: 0 tells Ansible to 'fire and forget' the command. If you don't include this then Ansible will kill the process when it returns from the remote server.
Another possibility is to use an init script. The thread I linked to above points to a location where you should be able to find an init script. You could install that (and leave it disabled if you don't want jboss to start up when the system reboots), and then simply run it via the service command from Ansible:
- name: start jboss
service: name=jboss state=started
Edit: If you're unwilling or unable to use nohup or an init script that puts jboss into the background then another alternative is to make use of screen if you have that installed and available to you. I regularly do this when invoking long-running commands from Ansible so that I can check back well after the playbook has been run to check on the status of the command:
- name: Invoke long running command
command: /usr/bin/screen -d -m /path/to/my/command
async: True
poll: 0
This will launch a detached screen session and invoke your command inside it. Ansible will promptly forget about it, leaving the command to run on its own.