-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathletu-dev.go
56 lines (45 loc) · 1.37 KB
/
letu-dev.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
// Go letu parser service
// TODO: single mongo connection, close on SIGTERM, SIGINT
import (
"os"
"fmt"
"goldapple"
"gopkg.in/mgo.v2"
"github.com/blackjack/syslog"
)
// goroutine handler
func _main() {
var C_HOST = "0.0.0.0"
var C_PORT = "9800"
var LetuBrandCollection = "letu_brands"
var ENV_PREF = "dev"
var LetuDB string = os.Getenv("LETU_MONGO_DB")
// Inject variable to goldapple pkg
goldapple.ENV_PREF = ENV_PREF
syslog.Openlog("letu_parser_"+ENV_PREF, syslog.LOG_PID, syslog.LOG_USER)
syslog.Syslog(syslog.LOG_INFO, "Start LETU parser ... " + C_HOST + ":" + C_PORT)
session, err := mgo.Dial("mongodb://apidev:apidev@localhost:27017/parser")
if err != nil {
//fmt.Println("Mongo connection error: ", err)
//syslog.Critf("Rive error: %s", err)
syslog.Err("Mongo connection refused. Not started ?")
os.Exit(1)
}
coll := goldapple.MakeTimePrefix(LetuBrandCollection)
if LetuDB == "" {
LetuDB = "parser"
}
c := session.DB(LetuDB).C(coll)
session.SetMode(mgo.Monotonic, true)
num, err := c.Count()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Today allready parsed count:", num)
}
goldapple.Step1(session)
//goldapple.Step2(session)
//goldapple.Step3(session)
//goldapple.Chanel(session)
}