Create client daemon
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.log
|
||||||
|
*.pid
|
||||||
33
main.go
Normal file
33
main.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/sevlyar/go-daemon"
|
||||||
|
"gitlab.com/saburly/kiviscraplib/workerclient"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
cntxt := &daemon.Context{
|
||||||
|
PidFileName: "sample.pid",
|
||||||
|
PidFilePerm: 0644,
|
||||||
|
LogFileName: "sample.log",
|
||||||
|
LogFilePerm: 0640,
|
||||||
|
WorkDir: "./",
|
||||||
|
Umask: 027,
|
||||||
|
Args: []string{"[kivi scraping worker client]"},
|
||||||
|
}
|
||||||
|
|
||||||
|
d, err := cntxt.Reborn()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Unable to run: ", err)
|
||||||
|
}
|
||||||
|
if d != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO: Handle error
|
||||||
|
defer cntxt.Release()
|
||||||
|
|
||||||
|
go workerclient.StartClientConnections()
|
||||||
|
|
||||||
|
select {} // Wait forever
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user