本文整理汇总了Golang中github.com/lxc/lxd/shared.PrintStack函数的典型用法代码示例。如果您正苦于以下问题:Golang PrintStack函数的具体用法?Golang PrintStack怎么用?Golang PrintStack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PrintStack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dbQueryRowScan
func dbQueryRowScan(db *sql.DB, q string, args []interface{}, outargs []interface{}) error {
for {
err := db.QueryRow(q, args...).Scan(outargs...)
if err == nil {
return nil
}
if !isDbLockedError(err) {
shared.Debugf("DbQuery: query %q error %q\n", q, err)
return err
}
shared.Debugf("DbQueryRowScan: query %q args %q, DB was locked\n", q, args)
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例2: dbBegin
func dbBegin(db *sql.DB) (*sql.Tx, error) {
for {
tx, err := db.Begin()
if err == nil {
return tx, nil
}
if !isDbLockedError(err) {
shared.Debugf("DbBegin: error %q\n", err)
return nil, err
}
shared.Debugf("DbBegin: DB was locked\n")
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例3: txCommit
func txCommit(tx *sql.Tx) error {
for {
err := tx.Commit()
if err == nil {
return nil
}
if !isDbLockedError(err) {
shared.Debugf("Txcommit: error %q\n", err)
return err
}
shared.Debugf("Txcommit: db was locked\n")
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例4: dbQueryScan
/*
* . q is the database query
* . inargs is an array of interfaces containing the query arguments
* . outfmt is an array of interfaces containing the right types of output
* arguments, i.e.
* var arg1 string
* var arg2 int
* outfmt := {}interface{}{arg1, arg2}
*
* The result will be an array (one per output row) of arrays (one per output argument)
* of interfaces, containing pointers to the actual output arguments.
*/
func dbQueryScan(db *sql.DB, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error) {
for {
result, err := doDbQueryScan(db, q, inargs, outfmt)
if err == nil {
return result, nil
}
if !isDbLockedError(err) {
shared.Debugf("DbQuery: query %q error %q\n", q, err)
return nil, err
}
shared.Debugf("DbQueryscan: query %q inargs %q, DB was locked\n", q, inargs)
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例5: dbExec
func dbExec(db *sql.DB, q string, args ...interface{}) (sql.Result, error) {
for {
result, err := db.Exec(q, args...)
if err == nil {
return result, nil
}
if !isDbLockedError(err) {
shared.Debugf("DbExec: query %q error %q\n", q, err)
return nil, err
}
shared.Debugf("DbExec: query %q args %q, DB was locked\n", q, args)
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例6: dbExec
func dbExec(db *sql.DB, q string, args ...interface{}) (sql.Result, error) {
for i := 0; i < 100; i++ {
result, err := db.Exec(q, args...)
if err == nil {
return result, nil
}
if !isDbLockedError(err) {
shared.Debugf("DbExec: query %q error %q", q, err)
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
shared.Debugf("DbExec: query %q args %q, DB still locked", q, args)
shared.PrintStack()
return nil, fmt.Errorf("DB is locked")
}
示例7: dbQueryScan
/*
* . q is the database query
* . inargs is an array of interfaces containing the query arguments
* . outfmt is an array of interfaces containing the right types of output
* arguments, i.e.
* var arg1 string
* var arg2 int
* outfmt := {}interface{}{arg1, arg2}
*
* The result will be an array (one per output row) of arrays (one per output argument)
* of interfaces, containing pointers to the actual output arguments.
*/
func dbQueryScan(db *sql.DB, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error) {
for i := 0; i < 100; i++ {
result, err := doDbQueryScan(db, q, inargs, outfmt)
if err == nil {
return result, nil
}
if !isDbLockedError(err) {
shared.Debugf("DbQuery: query %q error %q", q, err)
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
shared.Debugf("DbQueryscan: query %q inargs %q, DB still locked", q, inargs)
shared.PrintStack()
return nil, fmt.Errorf("DB is locked")
}
示例8: txCommit
func txCommit(tx *sql.Tx) error {
for i := 0; i < 100; i++ {
err := tx.Commit()
if err == nil {
return nil
}
if !isDbLockedError(err) {
shared.Debugf("Txcommit: error %q", err)
return err
}
time.Sleep(100 * time.Millisecond)
}
shared.Debugf("Txcommit: db still locked")
shared.PrintStack()
return fmt.Errorf("DB is locked")
}
示例9: dbBegin
func dbBegin(db *sql.DB) (*sql.Tx, error) {
for i := 0; i < 100; i++ {
tx, err := db.Begin()
if err == nil {
return tx, nil
}
if !isDbLockedError(err) {
shared.Debugf("DbBegin: error %q", err)
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
shared.Debugf("DbBegin: DB still locked")
shared.PrintStack()
return nil, fmt.Errorf("DB is locked")
}
示例10: containersGet
func containersGet(d *Daemon, r *http.Request) Response {
for {
result, err := doContainersGet(d, d.isRecursionRequest(r))
if err == nil {
return SyncResponse(true, result)
}
if !shared.IsDbLockedError(err) {
shared.Debugf("DBERR: containersGet: error %q\n", err)
return InternalError(err)
}
// 1 s may seem drastic, but we really don't want to thrash
// perhaps we should use a random amount
shared.Debugf("DBERR: containersGet, db is locked\n")
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例11: dbQueryRowScan
func dbQueryRowScan(db *sql.DB, q string, args []interface{}, outargs []interface{}) error {
for {
err := db.QueryRow(q, args...).Scan(outargs...)
if err == nil {
return nil
}
if isNoMatchError(err) {
return err
}
if !isDbLockedError(err) {
shared.Log.Debug("DbQuery: query error", log.Ctx{"query": q, "args": args, "err": err})
return err
}
shared.Debugf("DbQueryRowScan: query %q args %q, DB was locked\n", q, args)
shared.PrintStack()
time.Sleep(1 * time.Second)
}
}
示例12: dbQueryRowScan
func dbQueryRowScan(db *sql.DB, q string, args []interface{}, outargs []interface{}) error {
for i := 0; i < 100; i++ {
err := db.QueryRow(q, args...).Scan(outargs...)
if err == nil {
return nil
}
if isNoMatchError(err) {
return err
}
if !isDbLockedError(err) {
return err
}
time.Sleep(100 * time.Millisecond)
}
shared.Debugf("DbQueryRowScan: query %q args %q, DB still locked", q, args)
shared.PrintStack()
return fmt.Errorf("DB is locked")
}
示例13: containersGet
func containersGet(d *Daemon, r *http.Request) Response {
for i := 0; i < 100; i++ {
result, err := doContainersGet(d, d.isRecursionRequest(r))
if err == nil {
return SyncResponse(true, result)
}
if !isDbLockedError(err) {
shared.LogDebugf("DBERR: containersGet: error %q", err)
return InternalError(err)
}
// 1 s may seem drastic, but we really don't want to thrash
// perhaps we should use a random amount
time.Sleep(100 * time.Millisecond)
}
shared.LogDebugf("DBERR: containersGet, db is locked")
shared.PrintStack()
return InternalError(fmt.Errorf("DB is locked"))
}
示例14: run
func run() error {
if len(os.Args) > 1 {
switch os.Args[1] {
case "forkstart":
return startContainer(os.Args[1:])
case "forkmigrate":
return migration.MigrateContainer(os.Args[1:])
/*
case "forkputfile" and "forkgetfile" handled specially in copyfile.go
*/
}
}
gnuflag.Usage = func() {
fmt.Printf("Usage: lxd [options]\n\nOptions:\n")
gnuflag.PrintDefaults()
}
gnuflag.Parse(true)
if *help {
// The user asked for help via --help, so we shouldn't print to
// stderr.
gnuflag.SetOut(os.Stdout)
gnuflag.Usage()
return nil
}
if *version {
fmt.Println(shared.Version)
return nil
}
// Configure logging
syslog := ""
if *syslogFlag {
syslog = "lxd"
}
err := shared.SetLogger(syslog, *logfile, *verbose, *debug)
if err != nil {
fmt.Printf("%s", err)
return nil
}
if gnuflag.NArg() != 0 {
gnuflag.Usage()
return fmt.Errorf("Unknown arguments")
}
if *cpuProfile != "" {
f, err := os.Create(*cpuProfile)
if err != nil {
fmt.Printf("Error opening cpu profile file: %s\n", err)
return nil
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
if *memProfile != "" {
go memProfiler()
}
neededPrograms := []string{"setfacl", "rsync", "tar", "xz"}
for _, p := range neededPrograms {
_, err := exec.LookPath(p)
if err != nil {
return err
}
}
if *printGoroutines > 0 {
go func() {
for {
time.Sleep(time.Duration(*printGoroutines) * time.Second)
shared.PrintStack()
}
}()
}
d, err := startDaemon()
if err != nil {
if d != nil && d.db != nil {
d.db.Close()
}
return err
}
var ret error
var wg sync.WaitGroup
wg.Add(1)
go func() {
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGPWR)
sig := <-ch
shared.Log.Info(
fmt.Sprintf("Received '%s signal', shutting down containers.", sig))
//.........这里部分代码省略.........
示例15: cmdDaemon
func cmdDaemon() error {
if *argCPUProfile != "" {
f, err := os.Create(*argCPUProfile)
if err != nil {
fmt.Printf("Error opening cpu profile file: %s\n", err)
return nil
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
if *argMemProfile != "" {
go memProfiler(*argMemProfile)
}
neededPrograms := []string{"setfacl", "rsync", "tar", "xz"}
for _, p := range neededPrograms {
_, err := exec.LookPath(p)
if err != nil {
return err
}
}
if *argPrintGoroutinesEvery > 0 {
go func() {
for {
time.Sleep(time.Duration(*argPrintGoroutinesEvery) * time.Second)
shared.PrintStack()
}
}()
}
d := &Daemon{
group: *argGroup,
SetupMode: shared.PathExists(shared.VarPath(".setup_mode"))}
err := d.Init()
if err != nil {
if d != nil && d.db != nil {
d.db.Close()
}
return err
}
var ret error
var wg sync.WaitGroup
wg.Add(1)
go func() {
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGPWR)
sig := <-ch
shared.Log.Info(
fmt.Sprintf("Received '%s signal', shutting down containers.", sig))
containersShutdown(d)
ret = d.Stop()
wg.Done()
}()
go func() {
<-d.shutdownChan
shared.Log.Info(
fmt.Sprintf("Asked to shutdown by API, shutting down containers."))
containersShutdown(d)
ret = d.Stop()
wg.Done()
}()
go func() {
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT)
signal.Notify(ch, syscall.SIGQUIT)
signal.Notify(ch, syscall.SIGTERM)
sig := <-ch
shared.Log.Info(fmt.Sprintf("Received '%s signal', exiting.", sig))
ret = d.Stop()
wg.Done()
}()
wg.Wait()
return ret
}