v.0.9.6 : Add PID file
This commit is contained in:
+24
-12
@@ -8,6 +8,9 @@
|
||||
// returns : 200 google.com
|
||||
//
|
||||
// Use a single LDAP connection protected by a mutex
|
||||
//
|
||||
// v0.9.6 : add PID file
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
@@ -23,24 +26,26 @@ import (
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/peterbourgon/ff"
|
||||
"github.com/tabalt/pidfile"
|
||||
)
|
||||
|
||||
const (
|
||||
version = "0.9.5"
|
||||
version = "0.9.6"
|
||||
)
|
||||
|
||||
var (
|
||||
logstream *syslog.Writer
|
||||
conLdap *ldap.Conn
|
||||
mutex sync.Mutex
|
||||
debug *bool
|
||||
listen *string
|
||||
ldapURL *string
|
||||
ldapBaseDN *string
|
||||
ldapUser *string
|
||||
ldapPass *string
|
||||
ldapAttr *string
|
||||
defDomain *string
|
||||
logstream *syslog.Writer
|
||||
conLdap *ldap.Conn
|
||||
mutex sync.Mutex
|
||||
debug *bool
|
||||
listen *string
|
||||
ldapURL *string
|
||||
ldapBaseDN *string
|
||||
ldapUser *string
|
||||
ldapPass *string
|
||||
ldapAttr *string
|
||||
defDomain *string
|
||||
pidFilePath *string
|
||||
)
|
||||
|
||||
func ldapSearch(searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult, error) {
|
||||
@@ -212,6 +217,7 @@ func main() {
|
||||
ldapPass = fs.String("ldapPass", "", "LDAP user password (also via LDAPPASS env var)")
|
||||
ldapAttr = fs.String("ldapAttr", "relayName", "LDAP attribute containing the relay name to return")
|
||||
defDomain = fs.String("domain", "", "Domain to add to relay name if not a FQDN (also via DOMAIN env var)")
|
||||
pidFilePath= fs.String("pidfile", "/var/run/mxrouter/mxrouter.pid", "PID File (also via PIDFILE env var)")
|
||||
_ = fs.String("config", "", "config file (optional)")
|
||||
|
||||
// Surcharge de la fonction Usage()
|
||||
@@ -227,6 +233,12 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if pid, err := pidfile.Create(*pidFilePath); err != nil {
|
||||
log.Fatal(err)
|
||||
} else {
|
||||
defer pid.Clear()
|
||||
}
|
||||
|
||||
if logstream, e = syslog.New(syslog.LOG_MAIL, "mxrouter"); e != nil {
|
||||
log.Fatal(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user