Unworking named pipe shit. Go sockets instead!
This commit is contained in:
parent
f3080f5293
commit
4f3d3952f0
@ -45,7 +45,7 @@ func (r Request) ResponsePath() string {
|
|||||||
|
|
||||||
func Send(data Request) {
|
func Send(data Request) {
|
||||||
pipePath := PipePath()
|
pipePath := PipePath()
|
||||||
pipe, err := os.OpenFile(pipePath, os.O_APPEND, os.ModeNamedPipe)
|
pipe, err := os.OpenFile(pipePath, os.O_RDWR, os.ModeNamedPipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Failed to open", pipePath, ":", err)
|
log.Println("Failed to open", pipePath, ":", err)
|
||||||
log.Fatalln("Is the reaction daemon running? Does the CLI run as the same user?")
|
log.Fatalln("Is the reaction daemon running? Does the CLI run as the same user?")
|
||||||
|
18
app/pipe.go
18
app/pipe.go
@ -3,11 +3,11 @@ package app
|
|||||||
import (
|
import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"errors"
|
"errors"
|
||||||
"io/fs"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@ -111,7 +111,7 @@ func (r ReadableMap) ToString() string {
|
|||||||
|
|
||||||
// Pipe-related, server-related functions
|
// Pipe-related, server-related functions
|
||||||
|
|
||||||
func createOpenPipe() fs.File {
|
func createOpenPipe() *os.File {
|
||||||
err := os.Mkdir(RuntimeDirectory(), 0755)
|
err := os.Mkdir(RuntimeDirectory(), 0755)
|
||||||
if err != nil && !errors.Is(err, os.ErrExist) {
|
if err != nil && !errors.Is(err, os.ErrExist) {
|
||||||
log.Fatalln("FATAL Failed to create runtime directory", err)
|
log.Fatalln("FATAL Failed to create runtime directory", err)
|
||||||
@ -156,7 +156,19 @@ func Serve() {
|
|||||||
var request Request
|
var request Request
|
||||||
err := gob.NewDecoder(pipe).Decode(&request)
|
err := gob.NewDecoder(pipe).Decode(&request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("WARN Invalid Message received: ", err)
|
d, _ := time.ParseDuration("1s")
|
||||||
|
if err.Error() == "EOF" {
|
||||||
|
log.Println("DEBUG received EOF, seeking one byte")
|
||||||
|
_, err = pipe.Seek(1, 1)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("DEBUG failed to seek:", err)
|
||||||
|
}
|
||||||
|
time.Sleep(d)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Println("WARN Invalid Message received:", err)
|
||||||
|
time.Sleep(d)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
go func(request Request) {
|
go func(request Request) {
|
||||||
var response Response
|
var response Response
|
||||||
|
Loading…
Reference in New Issue
Block a user