Giter VIP home page Giter VIP logo

autotee's People

Contributors

fxkr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

autotee's Issues

Improve screen names

  • Put source/sink name in screen name
  • Put screen PID in log messages
  • Log message shows wrong screen name

Version 1.0

autotee has been used in production more than once now. It's time to stabilize it. I need to think about what I want to have in a 1.0 release (and maintain forever).

Improve graceful termination code

Currently it's implemented like this in src/autotee/util_cmd.go:

// Graceful termination. Blocking!
func (c *Cmd) End() error {

    // Ignore errors; process may already be dead
    _ = syscall.Kill(c.cmd.Process.Pid, syscall.SIGTERM)
    time.Sleep(250 * time.Millisecond)
    _ = syscall.Kill(c.cmd.Process.Pid, syscall.SIGKILL)
    return <-c.WaitChannel()
}

The hardcoded sleep time that can't finish early is not optimal.

A better way would be to wait for either the timeout or a SIGPIPE, then wait4 in the signal handler. There are a couple of difficulties to overcome though:

  • There'd have to be only one goroutine doing all the wait4-ing because otherwise other goroutines doing graceful termination might miss their notification.
  • I think (I'm not sure atm) we also couldn't use normal Wait() anywhere anymore. Can we guarantee that no library ever Wait()s?
  • There is no good way to wait until the process and all of its children have died. Is it ok if we just ensure the parent process dies?
  • Does Wait() in go do more than the syscall? Is it even ok if we don't wait via gos Wait() function?

Or is there a better (safe!) way to implement graceful termination?

Allow variable-size buffers to improve memory efficiency?

Currently, all buffers in the buffer pool are fixed size. Maybe we could allocate variable-size buffers?

We'd have to be very careful not to harm performance (e.g. due to fragmentation, or allocation overhead, or deallocation cost / garbage collection). Maybe a custom allocator (e.g. a buddy allocator) would help, or maybe we should try using Gos allocator. We'd definitely have to do benchmarks.

Rename (NginxRtmp|Icecast|Static)Server to ...StreamList

a) we don't implement the server but the client
b) it's not even a fully featured client, it just gets the list of streams
c) doesn't fit in well with stream lists that arent retrieved from servers

=> something like "StreamList" would be more appropriate

Add more unit tests

autotee has been written very, very carefully, knowing that it'd be used in production and must never crash.

However manual testing can only go so far.

Depends on #1

starting with icecast in fails autotee.IcecastUrls-conversion

---
  # Alternatively:
  url: "http://live.ber.c3voc.de:8000/status-json.xsl"
  type: "icecast"
voc@minion5:~/music-transcoding$ autotee music-config.yml                                                                                                                                      2016-12-27 17:49:49
WARN[17:49:54] New stream                                    match=true stream="ambient_lounge.opus"
WARN[17:49:54] New stream                                    match=true stream="chaoswest_lounge.ogg"
panic: interface conversion: mapset.Set is autotee.IcecastUrls, not *mapset.threadSafeSet

goroutine 1 [running]:
panic(0x791cc0, 0xc4201661c0)
	/usr/lib/go/src/runtime/panic.go:500 +0x1a1
github.com/deckarep/golang-set.(*threadSafeSet).Difference(0xc4200d35a0, 0x994e40, 0xc420142890, 0xc42010f900, 0xc42013c7c0)
	/home/anton/Projects/go/src/github.com/deckarep/golang-set/threadsafe.go:96 +0x192
github.com/fxkr/autotee/src.(*App).Run(0xc420013c20, 0xc4200103d0, 0xc4200ac420)
	/home/anton/Projects/go/src/github.com/fxkr/autotee/src/app.go:88 +0x83f
github.com/fxkr/autotee/src.Main.func1(0xc42009a640, 0xc42009a640, 0xc42004db87)
	/home/anton/Projects/go/src/github.com/fxkr/autotee/src/main.go:73 +0x242
github.com/codegangsta/cli.HandleAction(0x77e940, 0xc4200d2c00, 0xc42009a640, 0x0, 0x0)
	/home/anton/Projects/go/src/github.com/codegangsta/cli/app.go:485 +0xd4
github.com/codegangsta/cli.(*App).Run(0xc42007f860, 0xc42000c400, 0x2, 0x2, 0x0, 0x0)
	/home/anton/Projects/go/src/github.com/codegangsta/cli/app.go:259 +0x74f
github.com/fxkr/autotee/src.Main()
	/home/anton/Projects/go/src/github.com/fxkr/autotee/src/main.go:77 +0x3a3
main.main()
	/home/anton/Projects/go/src/github.com/fxkr/autotee/autotee.go:6 +0x14

Possible optimization: make source -> flow channel buffered

That might make everything somewhat smoother.

However, it'd have to be MUCH smaller than bpc.BufferSize, otherwise things might get too unpredictable.

Before committing the feature, test if it actually improves performance.

Also, test both with and without source stall detection enabled.

Add a stream list provider that calls an external script

Things to think about:

  • Maybe we could then move nginx-rtmp / icecast support out of autotee too.
  • I'd like to avoid constantly forking.
    • And I don't want to invent a custom protocol for long-running stream list providers.
  • Should it really be pull based? Wouldn't it make sense to expose an API instead?
    • Hard to deploy / use? Not robust? Security problem? Complicated to write (need heartbeat or client could die and we'd never notice changes to streams anymore...)

Use golang.org/x/net/context

Cancellations and log context are currently implemented in a somewhat ad-hoc way (cancellation: channel closing + barriers, log context: by just passing the existing log context explicitly).

https://blog.golang.org/context may provide a better, or at least more standardized, way.

Maybe we could also do dependency injection that way, solving #1

Log *why* a sink was terminated

Log why a sink was terminated. We had one source/sink combination that always failed to get started. (Maybe something buffer size related?)

Future of screen usage: Remove entirely? Or use screen windows?

Whats wrong

The current model (depending on reuse_screens config var that is either one screen per kind of process or one screen per process) doesn't work too well:

  1. There are many screens. There is no quick way to switch between related screens.
  2. Users could go into screens and ctrl-c the processes. autotee will just restart them, but...
  3. Screens tend to look like gibberish because their size isn't explicitly set (and can't be without synthesizing screen config files).
  4. When processes quit, the screen is thrown away (unless it's reused, anyway), so the screens don't help for troubleshooting exiting processes.

How to improve

Idea 1

We could remove screen support entirely and just rely on log files.

Problem: we wouldn't be able to see ffmpegs interactive progress display anymore.

Idea 2

We could use one screen per flow, with subwindows for processes.

This would not solve most of the problems mentioned above.

It would also mean we'd have to find another way to give the PTYs to the screens. We can't just generate a screen config file because processes (for individual screen windows) need to be restarted dynamically.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.