~rek2/goTootRamdonVideo

3bad3366b0bc519a0cc64b9f2589c94b19c5b959 — rek2 3 years ago 8a86783
first changes to daemonize
4 files changed, 32 insertions(+), 0 deletions(-)

M README.md
M go.mod
M go.sum
M main.go
M README.md => README.md +5 -0
@@ 38,3 38,8 @@ password = `gopass show -o -f gotootramdonvideo/password`
[odysee]
feed_url = https://odysee.com/$/rss/@Hackernol:7 
```

# To end program
```
kill `cat goTootRamdonVideo.pid`
```

M go.mod => go.mod +2 -0
@@ 5,6 5,7 @@ go 1.17
require (
	github.com/mattn/go-mastodon v0.0.4
	github.com/mmcdole/gofeed v1.1.3
	github.com/sevlyar/go-daemon v0.1.5
	gopkg.in/ini.v1 v1.63.2
)



@@ 18,5 19,6 @@ require (
	github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
	github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
	golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
	golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect
	golang.org/x/text v0.3.2 // indirect
)

M go.sum => go.sum +3 -0
@@ 30,6 30,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sevlyar/go-daemon v0.1.5 h1:Zy/6jLbM8CfqJ4x4RPr7MJlSKt90f00kNM1D401C+Qk=
github.com/sevlyar/go-daemon v0.1.5/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=


@@ 46,6 48,7 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3ob
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug=
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

M main.go => main.go +22 -0
@@ 12,6 12,7 @@ import (

	"github.com/mattn/go-mastodon"
	"github.com/mmcdole/gofeed"
	"github.com/sevlyar/go-daemon"
	"gopkg.in/ini.v1"
)



@@ 26,6 27,27 @@ func main() {

	server, clientId, clientSecret, username, password, feedURL := readConfig()

	cntxt := &daemon.Context{
		PidFileName: "goTootRamdonVideo.pid",
		PidFilePerm: 0644,
		LogFileName: "goTootRamdonVideo.log",
		LogFilePerm: 0640,
		WorkDir:     "./",
		Umask:       027,
		Args:        []string{"[goTootRamdonVideo]"},
	}
	d, err := cntxt.Reborn()
	if err != nil {
		log.Fatal("Unable to run: ", err)
	}
	if d != nil {
		return
	}
	defer cntxt.Release()

	log.Print("- - - - - - - - - - - - - - -")
	log.Print("daemon started")

	c := mastodon.NewClient(&mastodon.Config{
		Server:       server,
		ClientID:     clientId,