summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimportd/main.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-21 07:45:13 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-21 07:45:13 (GMT)
commita71ce473ac19e8ba5cf69f0d1375807529d92b11 (patch)
treef3e79711efc559b4950bec18bc548634661908fb /src/helsinki.at/rhimportd/main.go
parent75dd88f110c117b7fc73b83b13efd2385347f1b9 (diff)
minor cleanup for session testing
Diffstat (limited to 'src/helsinki.at/rhimportd/main.go')
-rw-r--r--src/helsinki.at/rhimportd/main.go97
1 files changed, 49 insertions, 48 deletions
diff --git a/src/helsinki.at/rhimportd/main.go b/src/helsinki.at/rhimportd/main.go
index 51a406e..4b6ddf4 100644
--- a/src/helsinki.at/rhimportd/main.go
+++ b/src/helsinki.at/rhimportd/main.go
@@ -43,34 +43,7 @@ var (
//rhdl = log.New(ioutil.Discard, "[rhimportd-dbg]\t", log.LstdFlags)
)
-func main() {
- // web_addr_s := flag.String("web-addr", ":4080", "addr:port to listen on")
- // telnet_addr_s := flag.String("telnet-addr", ":4023", "addr:port to listen on")
- rdconf_s := flag.String("rdconf", "/etc/rd.conf", "path to the Rivendell config file")
- rdxport_url_s := flag.String("rdxport-url", "http://localhost/rd-bin/rdxport.cgi", "the url to the Rivendell web-api")
- temp_dir_s := flag.String("tmp-dir", os.TempDir(), "path to temporary files")
- local_fetch_dir_s := flag.String("local-fetch-dir", os.TempDir(), "path to files that can be imported using local://")
- help := flag.Bool("help", false, "show usage")
-
- flag.Parse()
- if *help {
- flag.Usage()
- return
- }
-
- conf, err := rhimport.NewConfig(rdconf_s, rdxport_url_s, temp_dir_s, local_fetch_dir_s)
- if err != nil {
- rhl.Println("Error reading configuration:", err)
- return
- }
-
- rddb, err := rhimport.NewRdDb(conf)
- if err != nil {
- rhl.Println("Error initializing Rivdenll DB:", err)
- return
- }
- defer rddb.Cleanup()
-
+func session_test(conf *rhimport.Config, rddb *rhimport.RdDbChan) {
sessions, err := rhimport.NewSessionStore(conf)
if err != nil {
rhl.Println("Error initializing Session Store:", err)
@@ -80,7 +53,7 @@ func main() {
store := sessions.GetInterface()
- ctx := rhimport.NewImportContext(conf, rddb.GetInterface(), "hugo")
+ ctx := rhimport.NewImportContext(conf, rddb, "hugo")
id, session, err := store.New(ctx)
if err != nil {
rhl.Printf("Error SessionStore.New(): %s", err)
@@ -93,39 +66,67 @@ func main() {
fmt.Printf("\n\nSESSION_STORE: %+v\n\n", sessions)
- time.Sleep(12 * time.Second)
+ time.Sleep(5 * time.Second)
+
+ store.Remove("hugo", id)
+ fmt.Printf("\n\nSESSION_STORE: %+v\n\n", sessions)
+
+ time.Sleep(6 * time.Second)
fmt.Printf("\n\nSESSION_STORE: %+v\n\n", sessions)
store.Remove("hugo", id)
fmt.Printf("\n\nSESSION_STORE: %+v\n\n", sessions)
+}
+
+func main() {
+ web_addr_s := flag.String("web-addr", ":4080", "addr:port to listen on")
+ telnet_addr_s := flag.String("telnet-addr", ":4023", "addr:port to listen on")
+ rdconf_s := flag.String("rdconf", "/etc/rd.conf", "path to the Rivendell config file")
+ rdxport_url_s := flag.String("rdxport-url", "http://localhost/rd-bin/rdxport.cgi", "the url to the Rivendell web-api")
+ temp_dir_s := flag.String("tmp-dir", os.TempDir(), "path to temporary files")
+ local_fetch_dir_s := flag.String("local-fetch-dir", os.TempDir(), "path to files that can be imported using local://")
+ help := flag.Bool("help", false, "show usage")
+
+ flag.Parse()
+ if *help {
+ flag.Usage()
+ return
+ }
+
+ conf, err := rhimport.NewConfig(rdconf_s, rdxport_url_s, temp_dir_s, local_fetch_dir_s)
+ if err != nil {
+ rhl.Println("Error reading configuration:", err)
+ return
+ }
+
+ rddb, err := rhimport.NewRdDb(conf)
+ if err != nil {
+ rhl.Println("Error initializing Rivdenll DB:", err)
+ return
+ }
+ defer rddb.Cleanup()
+
+ // go session_test(conf, rddb.GetInterface())
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
- for {
- time.Sleep(10 * time.Second)
- }
+ rhl.Println("starting web-ctrl")
+ StartControlWeb(*web_addr_s, conf, rddb.GetInterface())
+ rhl.Println("web-ctrl finished")
}()
- // wg.Add(1)
- // go func() {
- // defer wg.Done()
- // rhl.Println("starting web-ctrl")
- // StartControlWeb(*web_addr_s, conf, rddb.GetInterface())
- // rhl.Println("web-ctrl finished")
- // }()
-
- // wg.Add(1)
- // go func() {
- // defer wg.Done()
- // rhl.Println("starting telnet-ctrl")
- // StartControlTelnet(*telnet_addr_s, conf, rddb.GetInterface())
- // rhl.Println("telnet-ctrl finished")
- // }()
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ rhl.Println("starting telnet-ctrl")
+ StartControlTelnet(*telnet_addr_s, conf, rddb.GetInterface())
+ rhl.Println("telnet-ctrl finished")
+ }()
alldone := make(chan bool)
go func() {