Vert.x address already in use: bind - Not kill processes (Windows) - windows

I'm creating a simple REST Server using Vert.x on intelliJ IDEA. When I run to test it, processes never are stopped after clicking the stop button from intelliJ. I undestand this because if I try to run, stop and rerun will appear the error "Address already in use: bind" so each time I must search java processes and kill them by Task Manager. Someone know a better solution?

I resolved changing in my build.gradle.kts this line of code:
tasks.withType<JavaExec> { args = listOf("run", mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$launcherClassName", "--on-redeploy=$doOnChange")}
With this:
tasks.withType<JavaExec> { args = listOf("run", mainVerticleName, "--launcher-class=$launcherClassName", "--on-redeploy=$doOnChange")}
So I removed the "--redeploy=$watchForChange" and it works fine.

Related

GoLand setting terminal cells doesn't work

I'm using the tcell library to display terminal cell graphics.
While writing this project in GoLand, I've noticed that using a normal run configuration and running the program in the integrated terminal, I'm not seeing the cells getting set as intended, despite tcell not giving any errors.
Program:
package main
import (
"time"
"github.com/gdamore/tcell"
)
func main() {
screen, err := tcell.NewScreen()
if err != nil {
panic(err)
}
err = screen.Init()
if err != nil {
panic(err)
}
screen.SetCell(0, 0, tcell.StyleDefault, 'X')
screen.SetCell(1, 0, tcell.StyleDefault, 'X')
screen.SetCell(1, 1, tcell.StyleDefault, 'X')
screen.SetCell(10, 10, tcell.StyleDefault, 'X')
screen.Show()
time.Sleep(time.Second*5)
}
GoLand output:
The program works as expected when running through cmd:
How can I set a run configuration in GoLand to run my program in cmd, or some other form of terminal that will allow me to set cells like this?
Open Help | Find Action...
Type Registry and hit Enter.
Find go.run.processes.with.pty there and turn it on.
Please, keep in mind that it can cause problems with run configurations like failing green tests or vice versa, never finishing debug sessions, and so on. If you notice weird IDE behavior related to console output, please disable the registry option back.
I'm not sure if points on Y-axis do display properly inside the Run window.
I guess GoLands terminal is a fake terminal without real cursor addressability. There may not be a good solution if that is the case.
I’m the author of tcell and I use goland but I confess I always run my test programs in a real terminal rather than in the toy terminal that the IDE provides. This is true whether I use goland, visual studio code, or even the venerable emacs.
By using a new Batch run configuration, you can run a batch file to build the program, then run the program in a new cmd window.
In the run configuration in GoLand, set "Working directory" to the main package directory. Then set the script to a new batch file.
Here is the code in my batch file for my package client
go build
start cmd /C client.exe
Running this configuration will build the package, then run the program in a new external cmd window where the cells display properly.
This solution isn't great, because most of the advantages of the GoLand run configuration system are lost, including debugging, process management (stop / restart), and other build options.
Does anyone have a better solution?

Run Golang project in Sublime Text 3

I cannot find a suitable solution for my needs with running a Go project inside a Sublime Text 3 and seeing it's output in real-time.
If I try a build system from:
GoSublime - I can use run, it even runs and stops, but there is no output, which I need. It appears only when I cancel build - it's too late.
Official Golang Build from Go developers - I can build the project, and that's it. It allows to run 1 file (current) only, but I need the whole project.
I've tried to use flags for run command and to add *.go, but then I get *.go: no such file or directory
How do I see the output in real-time in one of these solutions? I've tried to create my own build system with shell_cmd = go run *.go, but stopping the process with Cancel build is not working then. Maybe you can explain how do I stop a running Go program? My mybuild.sublime-build is similar to this:
{
"env": {
"GOROOT": "/path/gosrc/go",
"GOPATH": "/path/godev"
},
"path": "$PATH:/path/gosrc/go/bin",
"working_dir": "/path/godev/src/github.com/user/program",
"cmd": "go run *.go",
"shell": true
}
..I can run Build and see the needed output, but how do I then stop a running process?
P.S. Program is not just executing and exiting - it's a service, so I should see the output when the needed actions happens.
I personally use GoSublime and go build . followed by running the app by name as a second command. Obviously this sucks in a lot of ways, but it kinda sorta works most of the time. It provides a nice fast way to check for compile errors, which is most of what I need.
Honestly, just running in a dedicated shell is nicer in every way.
AFAIK, there is no better Go build system available for Sublime Text (that isn't an endorsement, it sucks, just less than most).
I found a tutorial where I was able to run Go files on build in Sublime Text 3 here: https://www.alexedwards.net/blog/streamline-your-sublime-text-and-go-workflow
If you use Build With: Go - Run you get outputs, but if you are running for example a net/http local host in Go you won't be able to run multiple programs and cancel build also does not work.
Here is an example of simple fmt.Println output in Sublime Text 3:
> Environment:
> GOPATH=C:/Users/Christiaan/go
> Directory: C:\Users\Christiaan\Documents\02_Personal\04_Learning\09_Go\01_test
> Command: C:\Users\Christiaan\go\go1.15rc1\bin\go.exe run -v C:\Users\Christiaan\Documents\02_Personal\04_Learning\09_Go\01_test\test2.go
> Output:
command-line-arguments
gas_pedal: 22314 brake_pedal: 0 steering_wheel: 12562
> Elapsed: 3.856s
> Result: Success

Using intellij to debug a project with Grunt

I use intellij with a mean stack and i want to debug the js file of my server.
Until now, i launch "grunt serve" in a line command from the directory where my project is and i have no problem.
In intellij there is two way to debug a project with nodejs. You can use the remote debug configuration. This way is working but not very confortable. you have to stop the debugguer each time you made a change in your js files and you have to restart the debugguer....
Or you can configure a GruntJs configuration.
I try to use this way but i don't have the same behavior that i have when i launch "grunt serve" in a terminal from the project directory. The process stuck at the "concurrent:server".
this is my configuration from intellij :
And this is the line command generated by intellij
/usr/bin/node --debug-brk=36118 --expose_debug_as=v8debug /home/bryan/Documents/projects/subscriptions/node_modules/grunt/node_modules/grunt-cli/bin/grunt --gruntfile /home/bryan/Documents/projects/subscriptions/subscriptions/Gruntfile.js -v -d serve
So my question is : What's the difference between using "grunt serve" in a terminal or using a grunt debug configuration from intelliJ ?
Well i found theses links from intelliJ Support
Solution :
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206320279-AngularJS-debug-grunt-server-hangs-at-Running-concurrent-server-concurrent-task
Explanation :
http://stackoverflow.com/questions/19252310/how-to-fork-a-child-process-that-listens-on-a-different-debug-port-than-the-pare
The problem is likely caused by the way Grunt spawns child tasks. By >default, the spawned child process uses the same debug port as a parent >process - as a result the forked process is suspended and the >application 'stalls'. See >http://stackoverflow.com/questions/19252310/how-to-fork-a-child-process->that-listens-on-a-different-debug-port-than-the-pare, for example.
Please try adding process.execArgv = []; at the top of the gruntfile.js
at the top of your Gruntfile.js - does it help?
And yes adding process.execArgv = [] at the top of GruntFile.js remove the stuck of "concurrent:serve" but my breakpoints don't work on port:5858
before overwritting process.execArgv here is content :
[ '--debug-brk=40305', '--expose_debug_as=v8debug' ]
At the start of the "grunt serve" i have this :
/usr/bin/node --debug-brk=40305 --expose_debug_as=v8debug /home/bryan/Documents/projects/subscriptions/node_modules/grunt/node_modules/grunt-cli/bin/grunt --gruntfile /home/bryan/Documents/projects/subscriptions/subscriptions/Gruntfile.js serve
debugger listening on port 40305
Running "serve" task
And at the end :
Running "express:dev" (express) task
Stopping Express server
Starting background Express server
debugger listening on port 5858
Express server listening on 9000, in development mode
In the intellij debugger variables panel its show "Connected to localhost:40305"
When i use a second debug configuration with nodejs debug remote on port :5858 breakpoints are working but this is ugly as i have described in my first question.
i tried this solution but nothings changes :
https://stackoverflow.com/questions/21957411/debugging-grunt-with-intellij?rq=1
my gruntfiles already own theses properties :
express: { dev: { options: { script: 'app/server.js', debug: true } } },
and theses modifications at line 71 in this file node_modules\grunt-express-server\tasks\lib\server.js, changing '--debug' to '--debug-brk='don't affect debugging.

Running Play service from Gradle

I am attempting to use a Gradle task to run a Play service, but I'm finding the Gradle task will hang (presumably waiting for a return value from the Play bootstrap script).
What I'm doing from the Play side is simply:
sbt dist
Which produces a .zip distribution (like 'myproject.zip'), which I then expand where I want to run this service from.
On the Gradle side, I was thinking I would do something like this:
task start(type: Exec) {
workingDir "myproject/bin"
commandLine './myproject'
}
This does indeed start up the Play service just fine, but the Gradle task will hang indefinitely (until you do a control+C).
The most obvious thing that came to mind to try was something like:
task start(type: Exec) {
workingDir "myproject/bin"
commandLine 'nohup ./myproject &'
}
But that ends in a dead end:
Execution failed for task ':start'.
> A problem occurred starting process 'command 'nohup ./playservicetemplate &''
It seems like this is a really common use case, so I'm wondering if there is an obvious solution that I'm overlooking.
There is perhaps a more Gradle-ish way to do this, but I solved it by leveraging ProcessBuilder. My new task looks like:
task start {
ProcessBuilder builder = new ProcessBuilder("./myproject")
builder.directory(new File("myproject/bin"))
builder.start()
}
Obviously, you can get a lot fancier with this (a quick Google of 'java processbuilder' will net you pages upon pages of examples), but this will do the trick for my purposes.

Grails test-app updating function being tested and test print out problems

I am running grails 2.3.3 in a GGTS.
I am successfully running a single unit test for a service function within the Spring GGTS.
I am hoping to be able to use this unit test to develop the particular function - such an approach will really speed up my development going forward.
This means I need to make changes to the service function that is being tested and then retest over and over again (no doubt a sad reflection on my coding skills!). The problem is when I make a change to the logic or any log.debug output it does not come through in the test. In other words the test continues to run against the original service function and not the updated one.
In order for me to force it to use the updated function the only way I have found that will do this is to restart the GGTS!
Is there a command I can use in GGTS to force a test on the most recent version of the function I am testing?
Here are the commands I am using within the GTTS:
test-app unit: UtilsService
I do run a clean after a function update without any success:
test-app -clean
I am also struggling with getting additional output from within the test function - introducing 'println' or 'log.debug' commands results in a failure of the test.
It would be useful to know of a good link to documentation about the test syntax - I have looked at grails section 12 about testing in general.
Here is the test file:
package homevu1
import grails.test.mixin.TestFor
import spock.lang.Specification
/**
* See the API for {#link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
*/
#TestFor(UtilsService)
class UtilsServiceSpec extends Specification {
// to test utilSumTimes for example use the command :
// test-app utilSumTimes
// test-app HotelStay
def setup() {
}
def cleanup() {
}
void "test something"() {
when:
def currSec = service.utilSumTimeSecs( 27, 1, false)
//println "currSec" , currSec
then:
//println "currSec" , currSec
assert currSec == "26"
}
}
If I uncomment either of the println lines these comments are not displayed and the test fails.
Welcome any suggestions.
-mike
I've to get this working now by running grail from a command prompt (in MS Windows).
In the command prompt I moved to the root folder/directory of the grails project - in my case:
cd C:\grails\workspace\rel_3.1.0\HomeVu
Then I type grails to start a grails command line session.
The unit test command I used being:
test-app -unit UtilsService -echoOut -echoErr
That said I still am unable to successfully put any print commands in the test file - but I can use the assert to determine any problems.
Also output from the last log.debug line of the grails code of the service function fails to appears. Perhaps there is some output buffering issue with MS Windows here.
At least I can now do some rapid function development, by making changes to the service/function code and instantly test is against a set of known requirement conditions.
Hope this helps others.
-mike

Resources