Почему мой сервер golang net/http останавливается через какое-то время?

У меня есть LXC с AlmaLinux8.7 и go1.19.5 linux/amd64 .

Кроме того, я компилирую программу сgo build main.goкоманда из этого кода:

      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)
   }
}

После успешной сборки я запускаю bin-файлmainс этой командой./main &и получил «PID 10651»

И мой сервер работает и у меня нет никаких ошибок.

Спустя долгое время, около суток у меня останавливается сервер или останавливается процесс go. Я понятия не имею, почему.

Я получаю запросы в go server от Nginx с другого сервера, Nginx в моем случае только запрос-прокси-сервер

Я сразу подумал об ОМ

      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"

но в логах не вижу свой PID 10651. Так же пытался найти ошибки в системных логах/var/log/messagesно результата не дает.

0 ответов

Другие вопросы по тегам