fxkr / autotee Goto Github PK
View Code? Open in Web Editor NEWan automatic process supervisor and stream multiplexer for video transcoding processes
License: BSD 3-Clause "New" or "Revised" License
an automatic process supervisor and stream multiplexer for video transcoding processes
License: BSD 3-Clause "New" or "Revised" License
e.g. error messages signal: killed
and exit status 1
(iirc)
Why do we even get them again?
Does it affect sources/sinks too?
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).
restart_when_sink_dies was true
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:
Or is there a better (safe!) way to implement graceful termination?
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.
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
Question: does killing the screen cause correct restarts?
This should be documented.
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
Currently, only if an entire parameter equals {stream}
, it's replaced by the stream name.
Though maybe we should switch to something like ${stream}
then, while we're at it?
---
# 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
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.
Currently graceful termination is only being done for screens.
Related to #3 -- for the sources/sinks, I think we really want to be sure all child processes are terminated.
Things to think about:
To allow paths relative to the config file.
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
Many options are not obvious. Especially the timers.
Currently only influxdb is supported.
Log why a sink was terminated. We had one source/sink combination that always failed to get started. (Maybe something buffer size related?)
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:
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.
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.
Zero-copy is the single most promising performance improvement. At the moment we clone:
See relevant todo in code:
Line 55 in e1813c7
A small source_timeout is desirable to minimize downtimes caused by source stalls.
However, sources may take some time to start.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.