0

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

3
  • Are you exiting your shell? You should not try to run a service by just starting it in the background with &. If you want to find out what signal your process is getting (other than SIGKILL), setup a signal handler in the process. Commented Feb 27, 2023 at 14:13
  • @JimB How can I start my service correctly? with a supervisor? Commented Feb 28, 2023 at 7:37
  • 1
    You use whatever init system your distribution provides, probably systemd in your case. Commented Feb 28, 2023 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.