process interrupted: signal: killed - go

I installed a utility called watcher.
https://github.com/canthefason/go-watcher
It works as expected using VS code.
But when I tried to use it in Goland (from Jetbrains) I get the following:
watcher main.go --port 8080
2020/03/04 14:10:42 build started
Building ....
2020/03/04 14:10:43 build completed
Running ...
2020/03/04 14:10:43 process interrupted: signal: killed
Needless to say go run main.go --port 8080 works.
I use a MAC Catalina.
Any suggestions?

Looks like an error from cmd.Wait()
if err := cmd.Wait(); err != nil {
log.Printf("process interrupted: %s \n", err)
...
A similar report was the OS killing the process because it was out of memory (OOM), and dmesg might have logged the error.

Related

AWS ECS WaitUntilTasksRunningWithContext returning ResourceNotReady

I'm not very proficient with Go but seeing the following error while waiting for an ECS task to start:
error waiting AWS ECS Task "arn:aws:ecs:eu-west-1:123456789012:task/ecs-cluster/22452be490a149e781a596a7847dd27c" to be in "Running" state: ResourceNotReady: failed waiting for successful resource state
The task being started has a launch type of EC2. Sometimes it will start, but fairly regularly it will return that error.
We get that while doing:
input := ecs.DescribeTasksInput{
Cluster: &cluster,
Tasks: []*string{&taskARN},
}
err = a.ecsSvc.WaitUntilTasksRunningWithContext(ctx, &input)
if err != nil {
return fmt.Errorf(`error waiting AWS Fargate Task %q to be in "Running" state: %w`, taskARN, err)
}
What would be the better solution here? To send in a custom WaiterOption to WaitUntilTasksRunningWithContext or to rather just retry the method if we get this failure?
For additional context. When checking in the console, I can see the task running, so this is most probably a case of WaitUntilTasksRunningWithContext returning too quickly.
If a retry is a good option, how would that look like?

How to fix: Chromedriver Page Immediately Closes

I run a program that tries to open a webpage using agouti/chromedriver in go, but as soon as it calls the new page, it closes the page. Subsequent attempts to access the page result in an "invalid session id" error. How can I get the page to stay open?
This is using Go (version 1.13.3 darwin/amd64) on Mac (version 10.14.5), with chromedriver (version 76.0.3809.68). I have the latest version of Google Chrome installed as well. I have tried updating chrome and agouti to no improved results. I have quit and restarted Chrome, uninstalled and reinstalled Chrome, and restarted my computer, none of which have worked. I have run with several chromedriver options (seen below), and run without them. I have tried with (seen below) and without time.Sleep() between functions. My regular chrome browser works fine.
package main
import (
"fmt"
"time"
"github.com/sclevine/agouti"
)
func main() {
driver := agouti.ChromeDriver(
agouti.ChromeOptions("args", []string{
"--headless",
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-gpu",
"--whitelisted-ips",
"--detach",
}),
agouti.Debug,
)
fmt.Println("start")
err := driver.Start()
if err != nil {
fmt.Println("Error starting driver: " + err.Error())
return
}
page, err := driver.NewPage(agouti.Browser("chrome"))
if err != nil {
fmt.Println("Error creating new page: " + err.Error())
return
}
time.Sleep(1 * time.Second)
err = page.Navigate("https://www.google.com")
if err != nil {
fmt.Println("Error navigating to job post link: " + err.Error())
return
}
time.Sleep(1 * time.Second)
fmt.Println("end")
}
When not using the --headless tag, I can see the browser window open and close in less than a second.
Expected output:
start
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-refs/branch-heads/3809#{#864}) on port 53489
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
end
Actual Output:
start
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-refs/branch-heads/3809#{#864}) on port 53489
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Error navigating to job post link: failed to navigate: request unsuccessful: invalid session id
I found the solution; turns out I needed to reinstall chromedriver. Looking back through my logs, the issue occurred due to Chrome automatically updating overnight, and no longer working with my previous version of chromedriver.

Client timeout exceeded while awaiting headers

I got below error, I am using go v1.10.4 linux/amd64.
I am not behind any firewall or whatsoever. New Relic in java server (same network segment) that we have runs fine.
We have tried:
Increasing the timeout to 60 seconds
Use http2 in the server
Using Postman return 503 with response:
{"exception":{"message":"Server Error","error_type":"RuntimeError"}}
troubleshooting with ./nrdiag says “No Issues Found”
Below is our code:
config := newrelic.NewConfig(os.Getenv("NEW_RELIC_APP_NAME"), os.Getenv("NEW_RELIC_KEY"))
config.Logger = newrelic.NewDebugLogger(os.Stdout)
app, err := newrelic.NewApplication(config)
if err != nil {
fmt.Println("Failed to create newrelic application", err)
os.Exit(1)
}
.................
httpListener, err := net.Listen("tcp", *httpAddr)
if err != nil {
oldlog.Print("Error: ", err)
logger.Log("transport", "HTTP", "during", "Listen", "err", err)
os.Exit(1)
}
g.Add(func() error {
logger.Log("transport", "HTTP", "addr", *httpAddr)
return http.Serve(httpListener, nrgorilla.InstrumentRoutes(httpHandler, app))
}, func(error) {
httpListener.Close()
})
}
However this what we got,note some_key was removed:
(28422) 2019/07/29 18:08:50.058559 {"level":"warn","msg":"application connect failure","context":{"error":"Post https://collector-001.eu01.nr-data.net/agent_listener/invoke_raw_method?license_key=some_key\u0026marshal_format=json\u0026method=connect\u0026protocol_version=17: net/http: request canceled (Client.Timeout exceeded while awaiting headers)"}}
I think it is due to DNS network timeout.
You can easily test this out by using the following steps (in Ubuntu)
Select the IPv4 Settings tab.
Disable the “Automatic” toggle switch and enter the DNS resolvers' IP addresses, separated by a comma. We’ll use the Google DNS nameservers:
8.8.8.8,8.8.4.4
If it works, then you may be able to reset the DNS to "Automatic"
On Windows OS, Running Linux Containers with WSL2, i followed the following steps,
Ran the command docker logout
Ran the command, docker network prune, so as to remove all the preconfigured settings of the network.
From Docker Settings, Enabled the DNS server configuration with 8.8.8.8
Restarted the Docker
Now executed login command with registry to login, docker login {registry}

Unable to create online web-page

I am trying to create Golang web-pages...
Progress:
Ubuntu 18.04 installed both locally and on a Linode VPS.
Created and compiled a local Golang "Hello World" script that renders OK both locally and online.
Created a net/http Golang script that works OK when called locally http://localhost:8080/testing to see if it works
Uploaded the script to the Linode server and initial status messages appear but when calling http:123.456.789.32:8080/testing to see if it works the browser freezes.
//
// Golang - main.go
//
package main
import (
"net/http"
)
func sayHello(w http.ResponseWriter, r *http.Request) {
message := r.URL.Path
message = "Hello " + message
w.Write([]byte(message))
}
func main() {
http.HandleFunc("/", sayHello)
if err := http.ListenAndServe(":8080", nil); err != nil {
panic(err)
}
}
There are no errors or warnings rendered and unable to find any log references.
Can error and warnings similar to PHP error_reporting(-1), declare(strict_types=1) etc be logged or rendered?
A quick check with Nmap showed this result:
nmap -sV -p 8080 <yourIP>
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-04 07:45 CEST
Nmap scan report for <your-domain>.com (<yourIP>)
Host is up (0.032s latency).
PORT STATE SERVICE VERSION
8080/tcp filtered http-proxy
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 0.90 seconds
The state of "filtered" actually means that there was no response on that port as opposed to an outright rejection of the request.
Check the output of iptables -L -n. Presumably, you have a firewall running and blocking port 8080. Do not simply deactivate the firewall, but read up on how to open port 8080 in the firewall product you are using. Linode has guides for the commonly used/preinstalled firewalls of various Linux distributions.
If you plan to go into production, please have someone help you to ensure security and availability of your deployment.

Get golang http server working with rerun

I'm trying to use rerun to relaunch a go http server when the source files change, but the restart always fails to launch.
Simple server
package main
import (
"net/http"
"fmt"
"log"
"html"
)
func main() {
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Command line output
$ rerun -p "**/*.{go,html}" go run my_server.go
16:49:24 [rerun] Rerun_test launched
16:49:26 [rerun] Watching . for **/*.{go,html} using Darwin adapter
16:50:17 [rerun] Change detected: 1 modified
16:50:17 [rerun] Sending signal TERM to 75688
16:50:17 [rerun] Rerun_test restarted
2014/07/15 16:50:17 listen tcp :8080: bind: address already in use
exit status 1
16:50:19 [rerun] Rerun_test Launch Failed
How can I get this working, or why can't the server bind to the port when it is relaunched?
Also, I am using OSX 10.9.
A process already running on port 8080 that's why it cannot re-run, go to your activity monitor find the process in your case it may be named as (my_server), and quit it.

Resources