castcaster 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/castcaster/channel.rb +4 -1
- data/lib/castcaster/cli.rb +1 -5
- data/lib/castcaster/config.rb +1 -2
- data/lib/castcaster/deploy/compose.rb +2 -2
- data/lib/castcaster/deploy/ffmpeg_services.rb +1 -1
- data/lib/castcaster/deploy/k8s.rb +3 -3
- data/lib/castcaster/deploy/swarm.rb +2 -2
- data/lib/castcaster/deploy.rb +1 -0
- data/lib/castcaster/engines/nginx_rtmp.rb +2 -2
- data/lib/castcaster/version.rb +1 -1
- data/lib/castcaster.rb +6 -0
- data/templates/deploy/k8s/deployment.yaml.erb +5 -1
- data/templates/deploy/k8s/deployment.yaml.tera +5 -1
- data/templates/nginx-rtmp/nginx.conf.erb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fc25e98798f5e17ea43d7d3a0c23f0803dc5ff13e7182464e4ce285414502d9
|
|
4
|
+
data.tar.gz: 798e995b0fe8a6669d959c12bc3675acf2a15d15c3b6cadc8503d072b102e99e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5d8314c5a5c895721d54cbc2f2154313d766d54f405ce867ff74b9396a9d81e1f7afc290c6ad88cfd60dd248dda112331247960eb2f8958489ee1da1c1ae07a
|
|
7
|
+
data.tar.gz: 07bde36a96d3f93de56be65cb0773192b469f865ebb8867e8cf1333f5fd8001f098affaea3e62cfefdbf64b86dc066429d64eb74bbf04f73f0c61a763285de0d
|
data/lib/castcaster/channel.rb
CHANGED
|
@@ -75,12 +75,15 @@ module CastCaster
|
|
|
75
75
|
def from_file(path)
|
|
76
76
|
data = YAML.safe_load(File.read(path))
|
|
77
77
|
unless data
|
|
78
|
-
warn "Warning:
|
|
78
|
+
warn "Warning: empty channel file: #{path}"
|
|
79
79
|
return nil
|
|
80
80
|
end
|
|
81
81
|
ch = new(data['name'], data)
|
|
82
82
|
ch.path = path
|
|
83
83
|
ch
|
|
84
|
+
rescue => e
|
|
85
|
+
warn "Warning: failed to parse channel file #{path}: #{e.message}"
|
|
86
|
+
nil
|
|
84
87
|
end
|
|
85
88
|
end
|
|
86
89
|
|
data/lib/castcaster/cli.rb
CHANGED
|
@@ -61,11 +61,7 @@ module CastCaster
|
|
|
61
61
|
say_status :created, path
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
IMAGES =
|
|
65
|
-
'nginx' => 'ghcr.io/lax/castcaster-nginx',
|
|
66
|
-
'ffmpeg' => 'ghcr.io/lax/castcaster-ffmpeg',
|
|
67
|
-
'webui' => 'ghcr.io/lax/castcaster-webui'
|
|
68
|
-
}.freeze
|
|
64
|
+
IMAGES = CastCaster::IMAGES
|
|
69
65
|
|
|
70
66
|
desc 'doctor', 'Check system environment'
|
|
71
67
|
def doctor
|
data/lib/castcaster/config.rb
CHANGED
|
@@ -40,8 +40,7 @@ module CastCaster
|
|
|
40
40
|
path = File.join(Dir.pwd, 'castcaster.token')
|
|
41
41
|
return File.read(path).strip if File.exist?(path)
|
|
42
42
|
token = SecureRandom.hex(32)
|
|
43
|
-
File.
|
|
44
|
-
File.chmod(0600, path)
|
|
43
|
+
File.open(path, 'w', 0600) { |f| f.write(token) }
|
|
45
44
|
token
|
|
46
45
|
end
|
|
47
46
|
|
|
@@ -33,7 +33,7 @@ module CastCaster
|
|
|
33
33
|
|
|
34
34
|
all = {
|
|
35
35
|
'nginx' => {
|
|
36
|
-
'image' => '
|
|
36
|
+
'image' => CastCaster::IMAGES['nginx'],
|
|
37
37
|
'restart' => 'unless-stopped',
|
|
38
38
|
'ports' => nginx_ports,
|
|
39
39
|
'volumes' => [
|
|
@@ -42,7 +42,7 @@ module CastCaster
|
|
|
42
42
|
]
|
|
43
43
|
},
|
|
44
44
|
'webui' => {
|
|
45
|
-
'image' => '
|
|
45
|
+
'image' => CastCaster::IMAGES['webui'],
|
|
46
46
|
'restart' => 'unless-stopped',
|
|
47
47
|
'volumes' => ["./channels:/channels:rw", "./hls:/var/lib/castcaster/hls:ro"],
|
|
48
48
|
'depends_on' => ['nginx'],
|
|
@@ -12,7 +12,7 @@ module CastCaster
|
|
|
12
12
|
name = ch.name
|
|
13
13
|
label = { 'castcaster/channel' => name }
|
|
14
14
|
common = {
|
|
15
|
-
'image' => '
|
|
15
|
+
'image' => CastCaster::IMAGES['ffmpeg'],
|
|
16
16
|
'restart' => 'unless-stopped',
|
|
17
17
|
'volumes' => ["#{hls_dir}:/var/lib/castcaster/hls"],
|
|
18
18
|
'depends_on' => ['nginx'],
|
|
@@ -34,9 +34,9 @@ module CastCaster
|
|
|
34
34
|
erb = ERB.new(tpl, trim_mode: '-')
|
|
35
35
|
ctx = TemplateContext.new(
|
|
36
36
|
app: 'castcaster',
|
|
37
|
-
engine_image: '
|
|
38
|
-
webui_image: '
|
|
39
|
-
ffmpeg_image: '
|
|
37
|
+
engine_image: CastCaster::IMAGES['nginx'],
|
|
38
|
+
webui_image: CastCaster::IMAGES['webui'],
|
|
39
|
+
ffmpeg_image: CastCaster::IMAGES['ffmpeg'],
|
|
40
40
|
engine_name: @engine.name,
|
|
41
41
|
channels_dir: File.join(@cfg.fetch('project_dir', Dir.pwd), 'channels'),
|
|
42
42
|
hls_dir: @cfg.fetch('hls_dir', '/var/lib/castcaster/hls'),
|
|
@@ -28,13 +28,13 @@ module CastCaster
|
|
|
28
28
|
def render
|
|
29
29
|
all = {
|
|
30
30
|
'nginx' => {
|
|
31
|
-
'image' => '
|
|
31
|
+
'image' => CastCaster::IMAGES['nginx'],
|
|
32
32
|
'restart' => 'unless-stopped',
|
|
33
33
|
'ports' => ['1935:1935', '8080:8080'],
|
|
34
34
|
'volumes' => ["./nginx/nginx.conf:/etc/nginx/nginx.conf:ro", "./hls:/var/lib/castcaster/hls"]
|
|
35
35
|
},
|
|
36
36
|
'webui' => {
|
|
37
|
-
'image' => '
|
|
37
|
+
'image' => CastCaster::IMAGES['webui'],
|
|
38
38
|
'restart' => 'unless-stopped',
|
|
39
39
|
'volumes' => ["./channels:/channels:rw"],
|
|
40
40
|
'environment' => {'HLS_DIR' => '/var/lib/castcaster/hls', 'CHANNELS_DIR' => '/channels'}
|
data/lib/castcaster/deploy.rb
CHANGED
data/lib/castcaster/version.rb
CHANGED
data/lib/castcaster.rb
CHANGED
|
@@ -6,6 +6,12 @@ require 'securerandom'
|
|
|
6
6
|
module CastCaster
|
|
7
7
|
class Error < StandardError; end
|
|
8
8
|
|
|
9
|
+
IMAGES = {
|
|
10
|
+
'nginx' => 'ghcr.io/lax/castcaster-nginx',
|
|
11
|
+
'ffmpeg' => 'ghcr.io/lax/castcaster-ffmpeg',
|
|
12
|
+
'webui' => 'ghcr.io/lax/castcaster-webui'
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
9
15
|
autoload :CLI, 'castcaster/cli'
|
|
10
16
|
autoload :Channel, 'castcaster/channel'
|
|
11
17
|
autoload :ChannelCLI, 'castcaster/channel_cli'
|
|
@@ -62,12 +62,16 @@ spec:
|
|
|
62
62
|
- name: webui
|
|
63
63
|
image: <%= webui_image %>
|
|
64
64
|
ports:
|
|
65
|
-
- containerPort:
|
|
65
|
+
- containerPort: 8081
|
|
66
66
|
env:
|
|
67
67
|
- name: STREAM_ENGINE
|
|
68
68
|
value: "<%= engine_name %>"
|
|
69
69
|
- name: STREAM_ENGINE_URL
|
|
70
70
|
value: "http://<%= app %>-stream:80"
|
|
71
|
+
- name: HLS_DIR
|
|
72
|
+
value: "<%= hls_dir || '/var/lib/castcaster/hls' %>"
|
|
73
|
+
- name: CHANNELS_DIR
|
|
74
|
+
value: "/channels"
|
|
71
75
|
volumeMounts:
|
|
72
76
|
- name: channels
|
|
73
77
|
mountPath: /channels
|
|
@@ -62,12 +62,16 @@ spec:
|
|
|
62
62
|
- name: webui
|
|
63
63
|
image: {{ webui_image }}
|
|
64
64
|
ports:
|
|
65
|
-
- containerPort:
|
|
65
|
+
- containerPort: 8081
|
|
66
66
|
env:
|
|
67
67
|
- name: STREAM_ENGINE
|
|
68
68
|
value: "{{ engine_name }}"
|
|
69
69
|
- name: STREAM_ENGINE_URL
|
|
70
70
|
value: "http://{{ app }}-stream:80"
|
|
71
|
+
- name: HLS_DIR
|
|
72
|
+
value: "{{ hls_dir | default(value="/var/lib/castcaster/hls") }}"
|
|
73
|
+
- name: CHANNELS_DIR
|
|
74
|
+
value: "/channels"
|
|
71
75
|
volumeMounts:
|
|
72
76
|
- name: channels
|
|
73
77
|
mountPath: /channels
|
|
@@ -42,8 +42,8 @@ rtmp {
|
|
|
42
42
|
drop_idle_publisher 25s;
|
|
43
43
|
hls on;
|
|
44
44
|
hls_path <%= hls_dir %>/<%= ch['name'] %>;
|
|
45
|
-
hls_fragment <%= ch.dig('hls', 'fragment') || 6
|
|
46
|
-
hls_playlist_length <%= ch.dig('hls', 'playlist_length') || 60
|
|
45
|
+
hls_fragment <%= ch.dig('hls', 'fragment') || 6 %>s;
|
|
46
|
+
hls_playlist_length <%= ch.dig('hls', 'playlist_length') || 60 %>s;
|
|
47
47
|
allow publish all;
|
|
48
48
|
allow play all;
|
|
49
49
|
}
|