forked from tildetown/town
further the rearranging
parent
0764534fed
commit
100643d8fc
|
@ -3,12 +3,12 @@ cmd/launcher/launcher
|
|||
cmd/request/request
|
||||
cmd/contrib/contrib
|
||||
cmd/visit/visit
|
||||
cmd/signup/signup
|
||||
cmd/review/review
|
||||
cmd/welcome/welcome
|
||||
cmd/createkeyfile/createkeyfile
|
||||
cmd/registeruser/registeruser
|
||||
cmd/stats/stats
|
||||
cmd/appendkeyfile/appendkeyfile
|
||||
cmd/help/help
|
||||
cmd/emailtouser/emailtouser
|
||||
external/cmd/signup/signup
|
||||
external/cmd/welcome/welcome
|
||||
external/cmd/help/help
|
||||
external/cmd/helpers/emailtouser/emailtouser
|
||||
external/cmd/helpers/createkeyfile/createkeyfile
|
||||
external/cmd/helpers/registeruser/registeruser
|
||||
external/cmd/helpers/appendkeyfile/appendkeyfile
|
||||
|
|
Binary file not shown.
|
@ -10,9 +10,9 @@ import (
|
|||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.tilde.town/tildetown/town/codes"
|
||||
"git.tilde.town/tildetown/town/external/lockingwriter"
|
||||
"git.tilde.town/tildetown/town/sshkey"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
@ -124,10 +124,8 @@ func (p *Prompter) Select(prompt string, opts []string) (int, error) {
|
|||
}
|
||||
|
||||
func _main(cs colorScheme) error {
|
||||
logFilename := fmt.Sprintf("/town/var/log/help/%d", time.Now().Unix())
|
||||
logFile, err := os.OpenFile(logFilename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||
l := log.New(logFile, "", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile)
|
||||
defer logFile.Close()
|
||||
lw := lockingwriter.New()
|
||||
l := log.New(lw, "help", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile|log.Lmsgprefix)
|
||||
|
||||
db, err := connectDB()
|
||||
if err != nil {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -134,7 +134,6 @@ func main() {
|
|||
}
|
||||
|
||||
func _main(l *log.Logger, db *sql.DB) error {
|
||||
l.Println("starting a session")
|
||||
pages := tview.NewPages()
|
||||
mainFlex := tview.NewFlex()
|
||||
input := tview.NewTextArea()
|
||||
|
@ -305,7 +304,6 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
/nod
|
||||
and pressing enter will cause you to nod. some other verbs: /quit /look`))
|
||||
case "quit":
|
||||
l.Println("got /quit")
|
||||
app.Stop()
|
||||
case "look":
|
||||
fmt.Fprintln(msgScroll, "")
|
||||
|
@ -314,8 +312,6 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
if !sm.Advance() {
|
||||
fmt.Fprintln(msgScroll, "you nod, but nothing happens.")
|
||||
fmt.Fprintln(msgScroll)
|
||||
} else {
|
||||
l.Println("advancing scene")
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -334,10 +330,7 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
msgScroll.ScrollToEnd()
|
||||
}
|
||||
|
||||
defer func() {
|
||||
l.Println("exiting")
|
||||
db.Close()
|
||||
}()
|
||||
defer db.Close()
|
||||
|
||||
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Key() {
|
||||
|
|
Binary file not shown.
|
@ -206,7 +206,7 @@ func createUser(data newUserData) (err error) {
|
|||
|
||||
func keyfileText(data newUserData) string {
|
||||
header := `########## GREETINGS! ##########
|
||||
# Hi! This file was automatically generated by tilde.town when
|
||||
# This file was automatically generated by tilde.town when
|
||||
# your account was created. You can edit it if you want, but we
|
||||
# recommend adding stuff to ~/.ssh/authorized_keys instead.`
|
||||
|
||||
|
|
Binary file not shown.
|
@ -13,10 +13,13 @@ type LockingWriter struct {
|
|||
path string
|
||||
}
|
||||
|
||||
const fp = "/town/var/log/external.log"
|
||||
const (
|
||||
fp = "/town/var/log/external.log"
|
||||
lp = "/town/var/log/log.lock"
|
||||
)
|
||||
|
||||
func NewLockingWriter() *LockingWriter {
|
||||
f, err := os.Create(fp)
|
||||
func New() *LockingWriter {
|
||||
f, err := os.OpenFile(fp, os.O_EXCL|os.O_CREATE|os.O_WRONLY, 0660)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -28,7 +31,7 @@ func NewLockingWriter() *LockingWriter {
|
|||
}
|
||||
|
||||
func (l *LockingWriter) Write(p []byte) (n int, err error) {
|
||||
fl := flock.New(l.path)
|
||||
fl := flock.New(lp)
|
||||
|
||||
var locked bool
|
||||
for !locked {
|
||||
|
@ -38,6 +41,7 @@ func (l *LockingWriter) Write(p []byte) (n int, err error) {
|
|||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
var f *os.File
|
||||
f, err = os.OpenFile(l.path, os.O_APPEND|os.O_WRONLY, 0600)
|
||||
if err != nil {
|
Loading…
Reference in New Issue