Compare commits
No commits in common. "8ef90ffd664eff7adcd8497352a87d162cad8ebe" and "c19817728489e048624ae2299aec612d642e6ea0" have entirely different histories.
8ef90ffd66
...
c198177284
|
@ -8,8 +8,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.kettek.net/accord/service/internal/cfg"
|
"git.kettek.net/accord/service/internal/cfg"
|
||||||
"git.kettek.net/accord/service/internal/version"
|
|
||||||
"git.kettek.net/accord/service/pkg/istty"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -20,15 +18,10 @@ func main() {
|
||||||
readChannel := make(chan AMessage)
|
readChannel := make(chan AMessage)
|
||||||
quitChannel := make(chan error)
|
quitChannel := make(chan error)
|
||||||
|
|
||||||
if istty.Is() {
|
|
||||||
fmt.Println("Running from TTY, starting as stand-alone service.")
|
|
||||||
fmt.Printf(" Git Id: %s\n", version.GitCommitId)
|
|
||||||
} else {
|
|
||||||
// Start our STDIN read loop
|
// Start our STDIN read loop
|
||||||
if cfg.UsePipes {
|
if cfg.UsePipes {
|
||||||
go readLoop(os.Stdin, quitChannel, readChannel)
|
go readLoop(os.Stdin, quitChannel, readChannel)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Begin waiting for data on our channels.
|
// Begin waiting for data on our channels.
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
// +build darwin,dragonfly,freebsd,linux,netbsd,openbsd,solaris
|
|
||||||
package version
|
|
||||||
|
|
||||||
//go:generate sh ./generate_nix.sh
|
|
|
@ -1,9 +0,0 @@
|
||||||
echo "// Code generated automatically; DO NOT EDIT." > version.go
|
|
||||||
echo "package version" >> version.go
|
|
||||||
echo "" >> version.go
|
|
||||||
echo "var (" >> version.go
|
|
||||||
echo " // GitCommitId provides the git commit id used to build this service." >> version.go
|
|
||||||
echo -n " GitCommitId string = \"" >> version.go
|
|
||||||
git log -n1 --format="%h" | tr -d '\n' >> version.go
|
|
||||||
echo "\"" >> version.go
|
|
||||||
echo ")" >> version.go
|
|
|
@ -1,7 +0,0 @@
|
||||||
// Code generated automatically; DO NOT EDIT.
|
|
||||||
package version
|
|
||||||
|
|
||||||
var (
|
|
||||||
// GitCommitId provides the git commit id used to build this service.
|
|
||||||
GitCommitId string = "c198177"
|
|
||||||
)
|
|
|
@ -1,17 +0,0 @@
|
||||||
package istty
|
|
||||||
|
|
||||||
// #cgo CFLAGS: -g -Wall
|
|
||||||
// #include "istty.h"
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Is returns if the process context is a TTY.
|
|
||||||
func Is() bool {
|
|
||||||
t := C.isTTY()
|
|
||||||
|
|
||||||
return bool(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close closes the TTY if possible.
|
|
||||||
func Close() {
|
|
||||||
C.closeTTY()
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
#ifdef _WIN32
|
|
||||||
#if _WIN32_WINNT < 0x0500
|
|
||||||
#undef _WIN32_WINNT
|
|
||||||
#define _WIN32_WINNT 0x0500
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "Wincon.h"
|
|
||||||
|
|
||||||
bool isTTY() {
|
|
||||||
HWND consoleWnd = GetConsoleWindow();
|
|
||||||
DWORD dwProcessId;
|
|
||||||
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
|
|
||||||
if (GetCurrentProcessId()==dwProcessId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void closeTTY() {
|
|
||||||
ShowWindow(GetConsoleWindow(), SW_HIDE);
|
|
||||||
}
|
|
||||||
#elif defined(__APPLE__) || defined(__linux) || defined(__unix) || defined(__posix)
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
bool isTTY() {
|
|
||||||
if (isatty(fileno(stdin))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void closeTTY() {}
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue