aboutsummaryrefslogtreecommitdiff
path: root/internal/cmd/trunks-example/main.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-10-17 02:33:09 +0700
committerShulhan <ms@kilabit.info>2021-10-17 02:33:09 +0700
commitd1bb05be9538a793fca37d3dcdcb8f637134398e (patch)
tree6e57b4f02a11fa0aa82b246b974e2181e8083883 /internal/cmd/trunks-example/main.go
parented3d14a77a3c2736c7b563bd52473c43a62f813b (diff)
downloadgorankusu-d1bb05be9538a793fca37d3dcdcb8f637134398e.tar.xz
all: move the main program for example to internal/cmd/trunks-example
The "cmd" directory on module should be reserved for installable program that can be executed outside of this repository. The trunks-example is development server should be run on root of this repository only, not installable to $GOBIN.
Diffstat (limited to 'internal/cmd/trunks-example/main.go')
-rw-r--r--internal/cmd/trunks-example/main.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/cmd/trunks-example/main.go b/internal/cmd/trunks-example/main.go
new file mode 100644
index 0000000..9c340e5
--- /dev/null
+++ b/internal/cmd/trunks-example/main.go
@@ -0,0 +1,37 @@
+// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//
+// Program trunks provide an example how to use the Trunks module.
+//
+package main
+
+import (
+ "os"
+ "os/signal"
+ "syscall"
+
+ "github.com/shuLhan/share/lib/mlog"
+
+ "git.sr.ht/~shulhan/trunks/example"
+)
+
+func main() {
+ ex, err := example.New()
+ if err != nil {
+ mlog.Fatalf("%s\n", err)
+ }
+
+ go func() {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
+ <-c
+ ex.Stop()
+ }()
+
+ err = ex.Start()
+ if err != nil {
+ mlog.Fatalf("%s\n", err)
+ }
+}