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
submodules: | submodules/bash-preexec/bash-preexec.sh
@# sets submodule.recurse to true if unset
@# sets status.submoduleSummary to true if unset
@ -44,3 +45,4 @@ submodules: | submodules/bash-preexec/bash-preexec.sh
submodules/%:
git submodule sync --recursive
git submodule update --init --recursive

@ -1,9 +1,12 @@
package main
import (
"bytes"
"encoding/json"
"os"
"os/exec"
"log"
"net/http"
"strconv"
"strings"
common "github.com/curusarn/resh/common"
@ -24,7 +27,27 @@ func main() {
Shell: os.Getenv("SHELL"),
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 {

@ -1,12 +1,5 @@
package common
import (
"bytes"
"encoding/json"
"net/http"
"log"
)
type Record struct {
CmdLine string `json: cmdLine`
Pwd string `json: pwd`
@ -16,22 +9,3 @@ type Record struct {
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) {
w.Write([]byte("OK\n"))
record := common.Record{}
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("git:", r.GitWorkTree)
// fmt.Println("exit_code:", r.ExitCode)
w.Write([]byte("OK\n"))
}
func server() {

Loading…
Cancel
Save