}
}
+func mkFifo(pth string) {
+ if _, err := os.Stat(pth); err == nil {
+ return
+ }
+ if err := syscall.Mkfifo(pth, 0666); err != nil {
+ log.Fatalln(err)
+ }
+}
+
func main() {
entrypoint := flag.String("entrypoint", mmc.GetEntrypoint(), "Entrypoint")
notifyCmd := flag.String("notify", "cmd/notify", "Path to notification handler")
UmaskCur = syscall.Umask(0)
syscall.Umask(UmaskCur)
- os.Remove("debug")
- err := syscall.Mkfifo("debug", 0666)
- if err != nil {
- log.Fatalln(err)
- }
+ mkFifo("debug")
+ var err error
DebugFd, err = os.OpenFile(
"debug", os.O_WRONLY|os.O_APPEND, os.FileMode(0666),
)
}
usersPth := path.Join(pth, "users")
- os.Remove(usersPth)
- if err := syscall.Mkfifo(usersPth, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(usersPth)
go func(ch *model.Channel) {
for {
time.Sleep(mmc.SleepTime)
}(ch)
pth = path.Join(pth, "in")
- os.Remove(pth)
- if err := syscall.Mkfifo(pth, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(pth)
go func(ch *model.Channel) {
for {
fd, err := os.OpenFile(pth, os.O_RDONLY, os.FileMode(0666))
}
statusPth := path.Join(pth, "status")
- os.Remove(statusPth)
- if err := syscall.Mkfifo(statusPth, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(statusPth)
go func(u *model.User) {
for {
time.Sleep(mmc.SleepTime)
}(u)
pth = path.Join(pth, "in")
- os.Remove(pth)
- if err := syscall.Mkfifo(pth, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(pth)
go func(u *model.User) {
var dc *model.Channel
for {
var UserStatusM sync.RWMutex
go func() {
pth := path.Join("users", "status")
- os.Remove(pth)
- if err := syscall.Mkfifo(pth, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(pth)
for {
time.Sleep(mmc.SleepTime)
fd, err := os.OpenFile(pth, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
go func() {
os.MkdirAll("file", 0777)
pthGet := path.Join("file", "get")
- os.Remove(pthGet)
- if err := syscall.Mkfifo(pthGet, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(pthGet)
pthOut := path.Join("file", "out")
- os.Remove(pthOut)
- if err := syscall.Mkfifo(pthOut, 0666); err != nil {
- log.Fatalln(err)
- }
+ mkFifo(pthOut)
for {
time.Sleep(mmc.SleepTime)
fd, err := os.OpenFile(pthGet, os.O_RDONLY, os.FileMode(0666))
unset TMUX
TMUX="tmux -S tmux.sock"
$TMUX has-session -t mmc 2>/dev/null && exit
-find . -type p -delete
[ -s tmux.conf ] || sed \
-e "s#NEWWIN#$cmd/newwin#" \
-e "s#CATFILE#$cmd/catfile#" \
-e "s#DLPANE#$cmd/dlpane#" < "$cmd"/tmux.conf > tmux.conf
$TMUX -f tmux.conf new-session -d -n ROOT -s mmc "while : ; do sleep 1 ; cat debug | tai64n | tai64nlocal ; done"
$TMUX split-window -h 'while : ; do sleep 10 ; clear ; cat users/status | spc -e grn,"^online:.*" -e cya,"^away:.*" ; done'
-$TMUX split-window -v "while : ; do $cmd/mmc/mmc -newwin $cmd/newwin -notify $cmd/notify | tai64n | tai64nlocal ; printf \"\\a\" ; sleep 1 ; done"
+$TMUX split-window -v "while : ; do $cmd/mmc/mmc -newwin $cmd/newwin -notify $cmd/notify | tai64n | tai64nlocal ; printf \"\\a\" ; sleep 10 ; done"
$TMUX attach-session