luispfcanales / go-service-daemon

goweb application running in daemon mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web http golang

func main() {
  http.HandleFunc("/",func(w http.ResponseWriter,r *http.Request){
    w.Write([]byte("Hi Gophers!"))
  })
  http.ListenAndServe(":80",nil)
}

List to learn

  • create file to execute as a service goweb.service

    [Unit]
    Description=descriptiton to application service
    ConditionPathExists=/ApplicationDirectoryPath
    After=network.target
    
    [Service]
    WorkingDirectory=/ApplicationDirectoryPath
    ExecStart=/ApplicationDirectoryPath/BinaryApp
    Restart=on-failure
    RestartSec=10
    
    [Install]
    WantedBy=multi-user.target
    
  • http web server running in daemon mode

    Commands to execute as a root user

    systemctl start nameService
    systemctl stop nameService
    systemctl enable nameService
    systemctl daemon-reload

About

goweb application running in daemon mode


Languages

Language:Go 100.0%