Merge branch 'master' into submodules_make

pull/1/head
Šimon Let 7 years ago committed by GitHub
commit c2940f7c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Makefile
  2. 25
      collect/resh-collect.go
  3. 26
      common/resh-common.go
  4. 2
      daemon/resh-daemon.go

@ -31,6 +31,7 @@ $(HOME)/.resh/bin:
.PHONY: submodules build install .PHONY: submodules build install
submodules: | submodules/bash-preexec/bash-preexec.sh submodules: | submodules/bash-preexec/bash-preexec.sh
@# sets submodule.recurse to true if unset @# sets submodule.recurse to true if unset
@# sets status.submoduleSummary to true if unset @# sets status.submoduleSummary to true if unset
@ -44,3 +45,4 @@ submodules: | submodules/bash-preexec/bash-preexec.sh
submodules/%: submodules/%:
git submodule sync --recursive git submodule sync --recursive
git submodule update --init --recursive git submodule update --init --recursive

@ -1,9 +1,12 @@
package main package main
import ( import (
"bytes"
"encoding/json"
"os" "os"
"os/exec" "os/exec"
"log" "log"
"net/http"
"strconv" "strconv"
"strings" "strings"
common "github.com/curusarn/resh/common" common "github.com/curusarn/resh/common"
@ -24,7 +27,27 @@ func main() {
Shell: os.Getenv("SHELL"), Shell: os.Getenv("SHELL"),
ExitCode: exitCode, ExitCode: exitCode,
} }
rec.Send() sendRecord(rec)
}
func sendRecord(r common.Record) {
recJson, err := json.Marshal(r)
if err != nil {
log.Fatal("1 ", err)
}
req, err := http.NewRequest("POST", "http://localhost:8888",
bytes.NewBuffer(recJson))
if err != nil {
log.Fatal("2 ", err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
_, err = client.Do(req)
if err != nil {
log.Fatal("resh-daemon is not running :(")
}
} }
func getGitDir() string { func getGitDir() string {

@ -1,12 +1,5 @@
package common package common
import (
"bytes"
"encoding/json"
"net/http"
"log"
)
type Record struct { type Record struct {
CmdLine string `json: cmdLine` CmdLine string `json: cmdLine`
Pwd string `json: pwd` Pwd string `json: pwd`
@ -16,22 +9,3 @@ type Record struct {
Logs []string `json: logs` Logs []string `json: logs`
} }
func (r Record) Send() {
recJson, err := json.Marshal(r)
if err != nil {
log.Fatal("1 ", err)
}
req, err := http.NewRequest("POST", "http://localhost:8888",
bytes.NewBuffer(recJson))
if err != nil {
log.Fatal("2 ", err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
_, err = client.Do(req)
if err != nil {
log.Fatal("resh-daemon is not running :(")
}
}

@ -13,6 +13,7 @@ func main() {
} }
func recordHandler(w http.ResponseWriter, r *http.Request) { func recordHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK\n"))
record := common.Record{} record := common.Record{}
jsn, err := ioutil.ReadAll(r.Body) jsn, err := ioutil.ReadAll(r.Body)
@ -32,7 +33,6 @@ func recordHandler(w http.ResponseWriter, r *http.Request) {
// fmt.Println("pwd:", r.Pwd) // fmt.Println("pwd:", r.Pwd)
// fmt.Println("git:", r.GitWorkTree) // fmt.Println("git:", r.GitWorkTree)
// fmt.Println("exit_code:", r.ExitCode) // fmt.Println("exit_code:", r.ExitCode)
w.Write([]byte("OK\n"))
} }
func server() { func server() {

Loading…
Cancel
Save