func main() { t0 := time.Now() conf := config.Config{} conf.MusicDir = flag.String("music-dir", "/music", "Music dir") conf.Port = flag.Int("port", 8080, "Pickup port") conf.MpdAddress = flag.String("mpd-address", "localhost:6600", "MPD address") conf.MpdPassword = flag.String("mpd-password", "", "MPD Password") flag.Parse(true) log.Printf("Mpd address: '%s' password: '******'\n", *conf.MpdAddress, *conf.MpdPassword) plyr, err := player.NewMpdPlayer(&conf) if err != nil { log.Fatalln("Failed to initialize mpd player", err) } music, err := plyr.GetCollection() if err != nil { log.Fatalln("Failed to retrieve collection", err) } log.Printf("Player with %d categories initialized in %v\n", len(music.Categories), time.Since(t0)) serve(&conf, &plyr) }
func main() { var action = flag.String("action", "serve", "Action to perform (serve|refresh)") conf := config.Config{} conf.MusicDir = flag.String("music-dir", "/music", "Music dir") conf.Port = flag.Int("port", 8080, "Pickup port") conf.MpdAddress = flag.String("mpd-address", "localhost:6600", "MPD address") conf.MpdPassword = flag.String("mpd-password", "", "MPD Password") var query = flag.String("query", "", "Search query") flag.Parse(true) fmt.Println("Action is:", *action) fmt.Printf("Mpd address: '%s' password: '******'\n", *conf.MpdAddress, *conf.MpdPassword) //collection := loadOrRefresh(*conf.MusicDir) music, err := model.RefreshMpd(&conf) if err != nil { log.Fatalf("Couldn't get files from mpd: \n%s\n", err) } switch *action { case "stats": stats(music.Categories[0]) case "search": search(music, *query) case "serve": serve(&conf, music) case "test-playback": testPlayback(&conf, music) case "refresh": os.Exit(0) default: fmt.Println("Unknown action", *action) } }
flag "launchpad.net/gnuflag" "log" "net/http" "os" "os/signal" "strconv" "strings" "syscall" "time" ) var VERSION string var MINVERSION string var helpFlag = flag.Bool("help", false, "Show this screen") var tracksFlag = flag.String("tracks", "", "Comma separated list of track_ids eg. 123,231,122") var fileFlag = flag.String("file", "", "A file of line separated track_ids") var playedTracksCount = map[string]int{} var tracks []TrackInfo var HTTP_ERR_RETRY = time.Duration(10) var HTTP_GET_ERROR = "HTTP GET for %s failed.\nWaiting 10s and trying again.." var HTTP_ETAG_GET_ERROR = "ETAG cached HTTP GET for %s failed.\nWaiting 10s and trying again.." func output_welcome() { fmt.Printf("\033]0;unearthd-bumpr v%s\007", VERSION) fmt.Println() fmt.Printf("Unearthd Track Bumpr - v%s\n", VERSION) fmt.Println("Created by NUR (Never Underestimate Reason)") fmt.Println() }
"unicode" ) var VERSION string var MINVERSION string var STD_OUT = bufio.NewWriter(colorable.NewColorableStdout()) var STD_ERR = bufio.NewWriter(colorable.NewColorableStderr()) var STD_IN = bufio.NewReader(os.Stdin) var DATABASE_FILENAME = "cover_urls.boltdb" var DATABASE_BUCKET = []byte("CoverImages") var DEFAULT_OUTPUT_FILENAME = "output.jpg" var aboutFlag = flag.Bool("about", false, "About the application") var trackListFlag = flag.String("tracklist", "", "A file containing a tracklist") var outputFileFlag = flag.String("output", "", "The file to output the generate cover to") var overlayFlag = flag.String("overlay", "", "A file to overlay on top of the generated image") func main() { flag.Parse(true) showWelcomeMessage() if *aboutFlag == true { showAboutMessage() os.Exit(0) } var tracklist []Track tracklistFileName := ""
func main() { foreground := flag.Bool("f", false, "Run application foreground, don't daemonize") config_path := flag.String("config", "config.json", "Configuration file path") pid_path := flag.String("pid", "/var/run/ng_backend.pid", "PID file path") flag.Parse(false) init_config(*config_path) d_config := get_daemon_config() state_config := get_state_config() metric_config := get_metric_config() graph_config := get_graph_config() if !*foreground { cntxt := &daemon.Context{ PidFileName: *pid_path, PidFilePerm: 0644, LogFileName: d_config.GetString("log_file"), LogFilePerm: 0640, WorkDir: "./", Umask: 027, Args: []string{}, } d, err := cntxt.Reborn() if err != nil { log.Fatalln(err) } if d != nil { return } defer cntxt.Release() } log.Println("Starting NetAssist NetGraphz2...") log.Printf("Create memory metric storage with capacity of %d records per metric\n", metric_config.GetInt("mem_storage.capacity")) metric_store := metric.NewMemoryStorage(metric_config.GetInt("mem_storage.capacity")) status_srv := state.NewStatusService(state.NewMemoryStateCache(), time.Duration(state_config.GetInt("cache.ttl"))*time.Millisecond) graph_store := graph.NewNeoGraphStorage(graph_config.GetString("url")) icinga_config := state.IcingaLiveStatusConfig{} icinga_config.HostName = state_config.GetString("icinga.host") icinga_config.Port = uint16(state_config.GetInt("icinga.port")) icinga_config.UseUnixSocket = state_config.GetBool("icinga.use_unix_socket") icinga_config.UnixSocket = state_config.GetString("icinga.unix_socket") icinga_config.TimeoutEnable = state_config.GetBool("icinga.timeout_enabled") icinga_config.Timeout = time.Duration(state_config.GetInt("icinga.timeout")) * time.Millisecond icinga_source := state.NewIcingaLiveStateSource(icinga_config) status_srv.AddSource(icinga_source) lis, err := net.Listen("tcp", net.JoinHostPort(d_config.GetString("rpc_host"), fmt.Sprintf("%d", d_config.GetInt("rpc_port")))) if err != nil { log.Printf("failed to listen: %v", err) } var opts []grpc.ServerOption grpcServer := grpc.NewServer(opts...) rpc.RegisterBackendServer(grpcServer, rpc_server.NewRPCServer(graph_store, status_srv, metric_store)) go func() { log.Printf("gRPC server starting on %s:%d\n", d_config.GetString("rpc_host"), d_config.GetInt("rpc_port")) err := grpcServer.Serve(lis) if err != nil { log.Fatalf("Error during listening: %v\n", err) } }() log.Printf("Starting collectd listener on %s:%d\n", metric_config.GetString("collectd.host"), metric_config.GetInt("collectd.port")) source := metric.NewCollectdMetricSource(metric_config.GetString("collectd.host"), uint16(metric_config.GetInt("collectd.port")), metric_config.GetBool("collectd.filter_enable"), metric_config.GetStringSlice("collectd.filter_types")) source.AddStorage(metric_store) log.Println("Collecting collectd metrics") source.Collect() }
// license that can be found in the LICENSE file. package tsuru import ( "encoding/json" "fmt" "github.com/globocom/tsuru/cmd" "io" "io/ioutil" "launchpad.net/gnuflag" "net/http" "strings" ) var AppName = gnuflag.String("app", "", "App name for running app related commands.") var LogLines = gnuflag.Int("lines", 10, "The number of log lines to display") var LogSource = gnuflag.String("source", "", "The log from the given source") type AppInfo struct { GuessingCommand } func (c *AppInfo) Info() *cmd.Info { return &cmd.Info{ Name: "app-info", Usage: "app-info [--app appname]", Desc: `show information about your app. If you don't provide the app name, tsuru will try to guess it.`, MinArgs: 0,
"sort" "time" "unicode/utf8" "github.com/juju/errors" "github.com/juju/juju/cmd/envcmd" "github.com/juju/juju/environs" "github.com/juju/juju/environs/configstore" "github.com/juju/juju/juju" "github.com/juju/juju/juju/osenv" "github.com/juju/juju/state/api" "github.com/juju/names" ) var ( envName = flag.String("e", "", "environment name") verbose = flag.Bool("v", false, "verbose") timeout = flag.Duration("timeout", 5*time.Minute, "maximum timeout") ) func main() { flag.Parse(true) if err := main0(); err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) } } var startTime = time.Now() func main0() error {
var OAUTH_REDIRECT_URI = "http://www.rhythmandpoetry.net/mixcloud_code.php" var API_URL = "https://api.mixcloud.com/upload/?access_token=" var ACCESS_TOKEN_URL = "https://www.mixcloud.com/oauth/access_token?client_id=" + OAUTH_CLIENT_ID + "&redirect_uri=" + OAUTH_REDIRECT_URI + "&client_secret=" + OAUTH_CLIENT_SECRET + "&code=%s" var API_ME_URL = "https://api.mixcloud.com/me?access_token=" var CONFIG_FILE = "config.json" var CONFIG_FILE_PATH = "" var TRACKLIST_OUTPUT_FORMAT = "%d. %s-%s\n" var CURRENT_USER mixcloud.User = mixcloud.User{} var configuration = Configuration{} var aboutFlag = flag.Bool("about", false, "About the application") var configFlag = flag.Bool("config", false, "Configure the application") var fileFlag = flag.String("file", "", "The mp3 file to upload to mixcloud") var coverFlag = flag.String("cover", "", "The image file to upload to mixcloud as the cover") var trackListFlag = flag.String("tracklist", "", "A file containing a VirtualDJ Tracklist for the cloudcast") var STD_OUT = bufio.NewWriter(colorable.NewColorableStdout()) var STD_ERR = bufio.NewWriter(colorable.NewColorableStderr()) var STD_IN = bufio.NewReader(os.Stdin) type Configuration struct { ACCESS_TOKEN string DEFAULT_TAGS string } func showWelcomeMessage() { OutputMessage(term.Green + "Mixcloud CLI Uploader v" + VERSION + term.Reset + "\n\n") }