Commit Graph

44 Commits

Author SHA1 Message Date
Ingo Oppermann
2ff8ce2c44 Simplify sending signals. Closing stdout on kill 2025-07-08 11:58:30 +02:00
Ingo Oppermann
93ba370c3a Close stdout pipe if process stays too long in finished state 2025-07-07 16:57:19 +02:00
Ingo Oppermann
15a0f4dbc5 Expose process ID 2025-07-07 12:09:20 +02:00
Ingo Oppermann
55314e35a8 Add option to disable CPU throttling 2025-06-24 16:52:51 +02:00
Ingo Oppermann
ba77ec0ecf Fix crash while stopping a process that is currently starting 2025-04-10 15:30:40 +02:00
Ingo Oppermann
e359420838 Make reconnect less prone to race conditions 2025-04-09 14:03:00 +02:00
Ingo Oppermann
2393dbc4c0 Add replacer tests, fix command in state with dynamic placeholders 2024-10-29 16:43:47 +01:00
Ingo Oppermann
2ee7fa7e41 Make resources the only direct user of psutil 2024-10-29 12:25:39 +01:00
Ingo Oppermann
412fbedea3 Make psutil a submodule of resources, remove default psutil 2024-10-28 16:13:13 +01:00
Ingo Oppermann
b6daea1a02 Remove unused parameter 2024-10-24 15:52:56 +02:00
Ingo Oppermann
2dbe5b5685 Add GPU support 2024-10-24 15:08:26 +02:00
Ingo Oppermann
1c56d53a6b Adjust comments 2024-08-21 17:02:22 +02:00
Ingo Oppermann
70a49f8bdb Process []byte instread of string in parser 2024-07-26 11:31:47 +02:00
Ingo Oppermann
72883d18d4 Remove bottlenecks in process handling, still some rough edges 2024-07-18 17:16:49 +02:00
Ingo Oppermann
b851249b98 Adjust process state if parser doesn't indicate that the process is producing output 2024-04-15 16:43:34 +02:00
Ingo Oppermann
88605a1f1e Put child processes in their own session
The core can be gracefully shutdown by sending a SIGINT to its process.
However, this signal is also propagated to all child processes, i.e. the
forked ffmpeg processes. They will also be stopped and might reconnect.
This is not wanted. The core has to stop these processes.

The child process will now get their own session ID with setsid() before
replacing themselves with ffmpeg. This way they will not receive a SIGINT
that was meant only for the parent.
2023-12-12 21:29:12 +01:00
Ingo Oppermann
8a8ff6d4f4 Add LimitMode and Resources.CPU.IsThrottling to process state 2023-07-17 21:45:19 +02:00
Ingo Oppermann
c8ab8567d9 Return error if onBeforeStart fails 2023-07-12 20:56:03 +02:00
Ingo Oppermann
72d56be9af Write stop/kill reason to process parser 2023-07-12 10:48:33 +02:00
Ingo Oppermann
4a4d33e529 Merge branch 'dev' into vod 2023-05-24 16:33:29 +02:00
Ingo Oppermann
4b2b6a57a1 Fix calling Wait after process has been read 2023-05-24 16:27:55 +02:00
Ingo Oppermann
06d7c6d0d4 Isolate order lock, call onExit later 2023-05-02 11:01:31 +02:00
Ingo Oppermann
ef138fb90f Limit CPU and memory independently, release CPU throttling incremently 2023-05-01 16:29:18 +02:00
Ingo Oppermann
f6d1cbbec2 WIP: release CPU throttling stepwise 2023-04-28 16:46:59 +02:00
Ingo Oppermann
7527f7833b Add resource manager 2023-04-27 17:02:20 +02:00
Ingo Oppermann
b723f4e5fd Propagate number of logical CPUs in resource usage 2023-04-27 10:58:41 +02:00
Ingo Oppermann
c9bdaae7f7 Call onExit if cmd.Start() fails 2023-04-26 22:17:08 +02:00
Ingo Oppermann
d59158de03 Allow hard and soft limiting a process
A hard limit will kill the process as soon as either CPU or memory
consumption are above a defined limit for a certain amount of time.

A soft limit will throttle the CPU usage if above a defined limit and
kill the process if memory consumption is above a defined limit. The
soft limit can be enabled/disabled on demand.

The default is hard limit.
2023-04-26 16:01:50 +02:00
Ingo Oppermann
a2dab2682f Fix not propagating process limits 2023-04-26 09:49:28 +02:00
Ingo Oppermann
9b17ab2b29 Add global limits in config, fix not using process limits 2023-04-25 21:49:55 +02:00
Ingo Oppermann
74f582e4b4 Remove debug output 2023-04-25 16:25:21 +02:00
Ingo Oppermann
9b6354ab94 Revert commit b58cc8a7ee 2023-04-25 15:57:17 +02:00
Ingo Oppermann
3a1825cf61 Expose resource usage in report history 2023-04-25 15:55:32 +02:00
Ingo Oppermann
3e7e5d5c9c Merge branch 'dev' into vod 2023-04-24 16:14:32 +02:00
Ingo Oppermann
b58cc8a7ee Fix race condition 2023-04-24 16:09:01 +02:00
Ingo Oppermann
b63b23527b Add scheduler and timeout to processes
The scheduler allows to define when a process should run. It can be either
a timestamp in RFC3339 format or a crontab expression. If a scheduler is
given, reconnect and the reconnect delay will only apply to processes that
exited as failed.

The timeout allows to define when a process should be gracefully stopped.
It is measured from the actual start of that process including all reconnects
due to failures. If the process finished regularly, the timeout will be
reset.
2023-03-21 14:51:43 +01:00
Ingo Oppermann
cceb39192a Fix receiving proper current command args, simplifying retrieval of last log line 2023-03-01 20:13:49 +01:00
Ingo Oppermann
86b3c053f1 Add exit state and last progress data to process report history 2023-03-01 15:28:28 +01:00
Ingo Oppermann
be718eac0a Add support for date placeholder in process config
Because it doesn't make sense to replace the date placeholder at
process creation, it has to be replaced at every start of the process.

On process creation only the static placeholders (such as process ID)
are replaced. Dynamic placeholders (so far only "date") are not
replaced. On process start, a callback has been introduced that gives
the chance to change the command line. This is the point where
the restreamer replaces the date placeholders.
2023-02-28 17:46:08 +01:00
Ingo Oppermann
1c04961fc1 Fix tests 2023-02-21 12:57:33 +01:00
Ingo Oppermann
50deaef4d3 Wait for process to exit when stopping
If a process has some cleanup with purge-on-delete defined, the purge
has to wait until the process actually exited. Otherwise it may happen
that the process got the signal, files are purged, but the process is
still writing some files in order to exit cleanly. This would lead to
some artefacts left on the filesystem.
2022-08-17 15:13:17 +03:00
Ingo Oppermann
3e7b1751d5 Add process id and reference glob pattern matching
For the API endpoint /v3/process two new query parameter are introduced
in order to list only processes that match a pattern for the id and the
reference: idpattern and refpattern. The pattern is a glob pattern. If
patterns for both are given, the results will be intersected. If you use
other query parameters such as id or reference, they will be applied
after the result of the pattern matching.
2022-08-17 07:55:44 +03:00
Jan Stabenow
eb1cc37456 Add GoSRT & improvements (repo-merge)
Commits (Ingo Oppermann):
- Add experimental SRT connection stats and logs
- Hide /config/reload endpoint in reade-only mode
- Add SRT server
- Create v16 in go.mod
- Fix data races, tests, lint, and update dependencies
- Add trailing slash for routed directories (datarhei/restreamer#340)
- Allow relative URLs in content in static routes

Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
2022-06-23 22:13:58 +02:00
Jan Stabenow
9c0b535199 Add v16.7.2 2022-05-13 19:26:45 +02:00