v.0.9.6 : Add PID file
This commit is contained in:
+13
-1
@@ -8,6 +8,9 @@
|
|||||||
// returns : 200 google.com
|
// returns : 200 google.com
|
||||||
//
|
//
|
||||||
// Use a single LDAP connection protected by a mutex
|
// Use a single LDAP connection protected by a mutex
|
||||||
|
//
|
||||||
|
// v0.9.6 : add PID file
|
||||||
|
//
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -23,10 +26,11 @@ import (
|
|||||||
|
|
||||||
"github.com/go-ldap/ldap/v3"
|
"github.com/go-ldap/ldap/v3"
|
||||||
"github.com/peterbourgon/ff"
|
"github.com/peterbourgon/ff"
|
||||||
|
"github.com/tabalt/pidfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "0.9.5"
|
version = "0.9.6"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -41,6 +45,7 @@ var (
|
|||||||
ldapPass *string
|
ldapPass *string
|
||||||
ldapAttr *string
|
ldapAttr *string
|
||||||
defDomain *string
|
defDomain *string
|
||||||
|
pidFilePath *string
|
||||||
)
|
)
|
||||||
|
|
||||||
func ldapSearch(searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult, error) {
|
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)")
|
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")
|
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)")
|
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)")
|
_ = fs.String("config", "", "config file (optional)")
|
||||||
|
|
||||||
// Surcharge de la fonction Usage()
|
// Surcharge de la fonction Usage()
|
||||||
@@ -227,6 +233,12 @@ func main() {
|
|||||||
return
|
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 {
|
if logstream, e = syslog.New(syslog.LOG_MAIL, "mxrouter"); e != nil {
|
||||||
log.Fatal(e)
|
log.Fatal(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user