Skip to content

Instantly share code, notes, and snippets.

func loadFromFile(configFile string, configStruct interface{}) error {
data, err := ioutil.ReadFile(configFile)
if err != nil {
return err
}
err = json.Unmarshal(data, configStruct)
if err != nil {
return err
}
// LogConfiguration specifies the level and file to use(if any)
type LogConfiguration struct {
Level string `json:"log_level"`
File string `json:"log_file"`
}
// ConfigureLogging will take the log config and optionally log to file
func ConfigureLogging(cfg *LogConfiguration) (*logrus.Entry, error) {
hostname, err := os.Hostname()
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"github.com/spf13/viper"
)
#
# implement a tree and add a method that will return a list
# of linked lists ordered by depth.
#
# a
# / \
# b d
# / / \
# e f g
#
#!/bin/bash
token=$1
out=$2
echo > $out
counter=0
while true; do
counter=$(( $counter + 1 ))
@rybit
rybit / diagnostics-1484067960.txt
Created January 10, 2017 17:15
influx debugging
name: build
Branch Build Time Commit Version
------ ---------- ------ -------
master e47cf1f2e83a02443d7115c54f838be8ee959644 1.1.1
name: network
hostname
--------
influxdb-0
fatal error: runtime: out of memory
runtime stack:
runtime.throw(0xa891db, 0x16)
/usr/local/go/src/runtime/panic.go:566 +0x95
runtime.sysMap(0xc787260000, 0x2e0000, 0x0, 0xe29ed8)
/usr/local/go/src/runtime/mem_linux.go:219 +0x1d0
runtime.(*mheap).sysAlloc(0xe10960, 0x2e0000, 0x1)
/usr/local/go/src/runtime/malloc.go:407 +0x37a
runtime.(*mheap).grow(0xe10960, 0x16b, 0x0)
@rybit
rybit / goroutine-1484184274.txt
Created January 12, 2017 17:15
influx debugging - 01..06
goroutine profile: total 106
14 @ 0x42fb0a 0x42fbfe 0x44a921 0x83c8c7 0x871e61 0x4607f1
# 0x44a920 time.Sleep+0xe0 /usr/local/go/src/runtime/time.go:59
# 0x83c8c6 github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).compactCache+0xd6 /root/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:953
# 0x871e60 github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).enableSnapshotCompactions.func1+0x60 /root/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:263
14 @ 0x42fb0a 0x42fbfe 0x44a921 0x83cca0 0x871c93 0x4607f1
# 0x44a920 time.Sleep+0xe0 /usr/local/go/src/runtime/time.go:59
# 0x83cc9f github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).compactTSMLevel+0x8f /root/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:979
# 0x871c92 github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).enableLevelCompactions.func2+0x72 /root/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:215
@rybit
rybit / pool.go
Created May 5, 2017 23:40
worker pool with timed shutdown
func StartWorkerPoolWithTimedShutdown(batchSize, numWorkers int, endpoint string) (chan<- string, chan time.Duration) {
externalShutdown := make(chan time.Duration)
work := make(chan string)
// use a sync.WaitGroup to ensure that we wait for all of the workers to Finished
wg := new(sync.WaitGroup)
// use a context with a cancel method to signal internally to shutdown the worker
ctx, cancel := context.WithCancel(context.Background())
ryan@rabbitmq-aws-jfk-1:~$ sudo rabbitmq-server start
RabbitMQ 3.6.9. Copyright (C) 2007-2016 Pivotal Software, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /var/log/rabbitmq/rabbitmq-aws-jfk-1.log
###### ## /var/log/rabbitmq/rabbitmq-aws-jfk-1-sasl.log
##########
Starting broker...