本文整理汇总了Golang中orchestra.Warn函数的典型用法代码示例。如果您正苦于以下问题:Golang Warn函数的具体用法?Golang Warn怎么用?Golang Warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UnixAudienceListener
func UnixAudienceListener(sockaddr string) {
fi, err := os.Stat(sockaddr)
if err == nil {
fmode := fi.Mode()
if fmode&os.ModeType == os.ModeSocket {
o.Warn("Removing stale socket at %s", sockaddr)
os.Remove(sockaddr)
} else {
o.Fail("%s exists and is not a socket", sockaddr)
}
}
laddr, err := net.ResolveUnixAddr("unix", sockaddr)
o.MightFail(err, "Couldn't resolve audience socket address")
l, err := net.ListenUnix("unix", laddr)
o.MightFail(err, "Couldn't start audience unixsock listener")
// Fudge the permissions on the unixsock!
fi, err = os.Stat(sockaddr)
if err == nil {
os.Chmod(sockaddr, fi.Mode()|0777)
} else {
o.Warn("Couldn't fudge permission on audience socket: %s", err)
}
// make sure we clean up the unix socket when we die.
defer l.Close()
defer os.Remove(sockaddr)
AudienceListener(l)
}
示例2: signalHandler
// handle the signals. By default, we ignore everything, but the
// three terminal signals, HUP, INT, TERM, we want to explicitly
// handle.
func signalHandler() {
for {
sig := <-signal.Incoming
ux, ok := sig.(os.UnixSignal)
if !ok {
o.Warn("Couldn't handle signal %s, Coercion failed", sig)
continue
}
switch int(ux) {
case syscall.SIGHUP:
o.Warn("Reloading Configuration")
reloadScores <- 1
case syscall.SIGINT:
fmt.Fprintln(os.Stderr, "Interrupt Received - Terminating")
//FIXME: Gentle Shutdown
os.Exit(1)
case syscall.SIGTERM:
fmt.Fprintln(os.Stderr, "Terminate Received - Terminating")
//FIXME: Gentle Shutdown
os.Exit(2)
}
}
}
示例3: signalHandler
// handle the signals. By default, we ignore everything, but the
// three terminal signals, HUP, INT, TERM, we want to explicitly
// handle.
func signalHandler() {
incoming := make(chan os.Signal)
signal.Notify(incoming, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
for {
sig := <-incoming
ux, ok := sig.(syscall.Signal)
if !ok {
o.Warn("*BUG* Couldn't handle signal %s, Coercion failed", sig)
continue
}
switch ux {
case syscall.SIGHUP:
o.Warn("Reloading Configuration")
ConfigLoad()
case syscall.SIGINT:
fmt.Fprintln(os.Stderr, "Interrupt Received - Terminating")
//FIXME: Gentle Shutdown
SaveState()
os.Exit(1)
case syscall.SIGTERM:
fmt.Fprintln(os.Stderr, "Terminate Received - Terminating")
//FIXME: Gentle Shutdown
os.Exit(2)
}
}
}
示例4: loadSpoolFiles
func loadSpoolFiles(dirname string, depth int) {
dh, err := os.Open(dirname)
o.MightFail(err, "Couldn't open %s", dirname)
nodes, err := dh.Readdir(-1)
o.MightFail(err, "Couldn't readdir on %s", dirname)
if depth > 0 {
for _, n := range nodes {
abspath := path.Join(dirname, n.Name())
if (n.Mode() & os.ModeType) == os.ModeDir {
// if not a single character, it's not a spool node.
if len(n.Name()) != 1 {
continue
}
if n.Name() == "." {
// we're not interested in .
continue
}
nrunes := []rune(n.Name())
if unicode.Is(unicode.ASCII_Hex_Digit, nrunes[0]) {
loadSpoolFiles(abspath, depth-1)
} else {
o.Warn("Foreign dirent %s found in spool tree", abspath)
}
}
}
} else {
// depth == 0 - only interested in files.
for _, n := range nodes {
abspath := path.Join(dirname, n.Name())
if n.Mode()&os.ModeType == 0 {
if len(n.Name()) != 16 {
shuffleToCorrupted(abspath, "Filename incorrect length")
continue
}
id, err := strconv.ParseUint(n.Name(), 16, 64)
if err != nil {
shuffleToCorrupted(abspath, "Invalid Filename")
continue
}
fh, err := os.Open(abspath)
if err != nil {
shuffleToCorrupted(abspath, "Couldn't open")
continue
}
defer fh.Close()
jr, err := JobRequestFromReader(fh)
if err != nil || jr.Id != id {
o.Warn("Couldn't parse?! %s", err)
shuffleToCorrupted(abspath, "Parse Failure")
continue
}
// Add the request to the registry directly.
if !RestoreJobState(jr) {
shuffleToCorrupted(abspath, "Job State Invalid")
}
}
}
}
}
示例5: LoadScores
func LoadScores() {
scoreDirectory := GetStringOpt("score directory")
dir, err := os.Open(scoreDirectory)
o.MightFail(err, "Couldn't open Score directory")
defer dir.Close()
Scores = make(map[string]*ScoreInfo)
files, err := dir.Readdir(-1)
for i := range files {
name := files[i].Name()
// skip ., .. and other dotfiles.
if strings.HasPrefix(name, ".") {
continue
}
// emacs backup files. ignore these.
if strings.HasSuffix(name, "~") || strings.HasPrefix(name, "#") {
continue
}
// .conf is reserved for score configurations.
if strings.HasSuffix(name, ".conf") {
continue
}
// check to see if it's a file or symlink
ftype := files[i].Mode() & os.ModeType
if ftype != 0 && ftype != os.ModeSymlink {
continue
}
// check for the executionable bit
if files[i].Mode()&0111 == 0 {
continue
}
fullpath := path.Join(scoreDirectory, name)
conffile := fullpath + ".conf"
o.Warn("Considering %s as score", name)
si := NewScoreInfo()
si.Name = name
si.Executable = fullpath
conf, err := os.Open(conffile)
if err == nil {
o.Warn("Parsing configuration for %s", fullpath)
ScoreConfigure(si, conf)
conf.Close()
} else {
o.Warn("Couldn't open config file for %s, assuming defaults: %s", name, err)
}
Scores[name] = si
}
}
示例6: sendNow
// Can only be used form inside of handlers and the main client loop.
func (client *ClientInfo) sendNow(p *o.WirePkt) {
_, err := p.Send(client.connection)
if err != nil {
o.Warn("Client %s: error sending packet: %s", client.Name(), err)
client.Abort()
}
}
示例7: signalHandler
// handle the signals. By default, we ignore everything, but the
// three terminal signals, HUP, INT, TERM, we want to explicitly
// handle.
func signalHandler() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
for {
sig := <-c
ux, ok := sig.(syscall.Signal)
if !ok {
o.Warn("Couldn't handle signal %s, coercion failed", sig)
continue
}
switch ux {
case syscall.SIGHUP:
o.Info("Reloading configuration...")
ConfigLoad()
case syscall.SIGINT, syscall.SIGTERM:
//FIXME: Gentle Shutdown
SaveState()
os.Exit(0)
}
}
}
示例8: connectMe
func connectMe(initialDelay int64) {
var backOff int64 = initialDelay
for {
// Sleep first.
if backOff > 0 {
o.Info("Sleeping for %d seconds", backOff/1e9)
err := time.Sleep(backOff)
o.MightFail(err, "Couldn't Sleep")
backOff *= ReconnectDelayScale
if backOff > MaximumReconnectDelay {
backOff = MaximumReconnectDelay
}
} else {
backOff = InitialReconnectDelay
}
tconf := &tls.Config{
RootCAs: CACertPool,
}
tconf.Certificates = append(tconf.Certificates, CertPair)
// update our local hostname.
LocalHostname = GetStringOpt("player name")
if LocalHostname == "" {
LocalHostname = o.ProbeHostname()
o.Warn("No hostname provided - probed hostname: %s", LocalHostname)
}
masterHostname := GetStringOpt("master")
raddr := fmt.Sprintf("%s:%d", masterHostname, 2258)
o.Info("Connecting to %s", raddr)
conn, err := tls.Dial("tcp", raddr, tconf)
if err == nil {
conn.Handshake()
err = conn.VerifyHostname(masterHostname)
}
if err == nil {
nc := new(NewConnectionInfo)
nc.conn = conn
nc.timeout = backOff
newConnection <- nc
return
}
o.Warn("Couldn't connect to master: %s", err)
}
}
示例9: SetSpoolDirectory
func SetSpoolDirectory(spooldir string) {
if spoolDirectory == "" {
spoolDirectory = spooldir
} else {
if spooldir != spoolDirectory {
o.Warn("Spool Directory Not Changed.")
}
}
}
示例10: shuffleToCorrupted
func shuffleToCorrupted(abspath, reason string) {
basename := path.Base(abspath)
targetname := path.Join(spoolDirectory, "corrupt", basename)
// make sure there's nothing in the target name.
os.Remove(targetname)
err := os.Rename(abspath, targetname)
o.MightFail(err, "Couldn't bin corrupt spoolfile %s", abspath)
o.Warn("Moved \"%s\" to corrupted spool: %s", abspath, reason)
}
示例11: SetSpoolDirectory
func SetSpoolDirectory(spooldir string) {
if spoolDirectory == "" {
spoolDirectory = spooldir
} else {
if spooldir != spoolDirectory {
o.Warn("Refusing to change spool directory as it's already set")
}
}
}
示例12: writeIdCheckpoint
func writeIdCheckpoint() {
fh, err := os.OpenFile(checkpointPath(), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
if err != nil {
o.Warn("Failed to create checkpoint file: %s", err)
return
}
defer fh.Close()
fmt.Fprintf(fh, "%d\n", lastId)
}
示例13: AudienceListener
func AudienceListener(l net.Listener) {
for {
c, err := l.Accept()
if err != nil {
o.Warn("Accept() failed on Audience Listenter.")
break
}
go handleAudienceRequest(c)
}
}
示例14: saveLastId
func saveLastId() {
fh, err := os.OpenFile(savePath(), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
if err != nil {
o.Warn("Failed to create last ID save file: %s", err)
return
}
defer fh.Close()
fmt.Fprintf(fh, "%d\n", lastId)
os.Remove(checkpointPath())
}
示例15: ConfigLoad
func ConfigLoad() {
// attempt to open the configuration file.
fh, err := os.Open(*ConfigFile)
if nil == err {
defer fh.Close()
// reset the config File data, then reload it.
configFile.Reset()
ierr := configFile.Read(fh, 1)
o.MightFail(ierr, "Couldn't parse configuration")
} else {
o.Warn("Couldn't open configuration file: %s. Proceeding anyway.", err)
}
playerpath := strings.TrimSpace(GetStringOpt("player file path"))
pfh, err := os.Open(playerpath)
o.MightFail(err, "Couldn't open \"%s\"", playerpath)
pbr := bufio.NewReader(pfh)
ahmap := make(map[string]bool)
for err = nil; err == nil; {
var lb []byte
var prefix bool
lb, prefix, err = pbr.ReadLine()
if nil == lb {
break
}
if prefix {
o.Fail("ConfigLoad: Short Read (prefix only)!")
}
line := strings.TrimSpace(string(lb))
if line == "" {
continue
}
if line[0] == '#' {
continue
}
ahmap[line] = true
}
// convert newAuthorisedHosts to a slice
authorisedHosts := make([]string, len(ahmap))
idx := 0
for k, _ := range ahmap {
authorisedHosts[idx] = k
idx++
}
ClientUpdateKnown(authorisedHosts)
// set the spool directory
SetSpoolDirectory(GetStringOpt("conductor state path"))
}