Why my golang net/http server is stopped after any time?

147 views Asked by At

I have an LXC with AlmaLinux8.7 and go1.19.5 linux/amd64.

Also, I compile the program with the go build main.go command from this code:

package main

import (
   "net/http"
   "log"
)

func main() {
   defer func() {
     if g := recover(); g != nil {
    log.Fatal("panic in main")
     }
   }()
   fs := http.FileServer(http.Dir("static"))
   http.Handle("/", fs)
   http.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
      w.Write([]byte("Text"))
   })
   err :=  http.ListenAndServe(":8090", nil)
   if err != nil {
    log.Fatal("ListenAndServe: ", err)
   }
}

After the build success, I run the bin file main with this command ./main & and got 'PID 10651'

And my server is working and I don`t have any errors.

After a long time, about a day my server is stopped or the go process is stopped. I don`t have any idea why.

I get requests in the go server from Nginx from another server, Nginx in my case is only the request-proxy server

I immediately thought of OOM

sudo dmesg | tail -7
[17849523.500746] audit: type=1400 audit(1677489732.392:307823): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-117_</var/lib/lxc>" name="/tmp/" pid=37138 comm="(kill)" flags="rw, remount, noatime, bind"
[17849642.899402] audit: type=1400 audit(1677489851.790:307824): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-123_</var/lib/lxc>" name="/tmp/" pid=1182 comm="(kill)" flags="rw, remount, noatime, bind"
[17849645.086122] audit: type=1400 audit(1677489853.978:307825): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-117_</var/lib/lxc>" name="/tmp/" pid=2189 comm="(kill)" flags="rw, remount, noatime, bind"
[17849762.861902] audit: type=1400 audit(1677489971.748:307826): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-123_</var/lib/lxc>" name="/tmp/" pid=8059 comm="(kill)" flags="rw, remount, noatime, bind"
[17849765.144016] audit: type=1400 audit(1677489974.032:307827): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-117_</var/lib/lxc>" name="/tmp/" pid=8703 comm="(kill)" flags="rw, remount, noatime, bind"
[17849881.579055] audit: type=1400 audit(1677490090.466:307828): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-123_</var/lib/lxc>" name="/tmp/" pid=14858 comm="(kill)" flags="rw, remount, noatime, bind"
[17849883.215388] audit: type=1400 audit(1677490092.102:307829): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-117_</var/lib/lxc>" name="/tmp/" pid=15223 comm="(kill)" flags="rw, remount, noatime, bind"

but in the logs, I don't see my PID 10651. I also tried to find errors in the system logs /var/log/messages but it does not get the result.

enter image description here

0

There are 0 answers