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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 473f74bfc9f9b8f427068f501fc5db2dc13071234084647028e13f487152dedd
4
- data.tar.gz: 8566513c993848a0160a91f6c548c1c0dcd1cfdd9a162decb5df4c5e5a0a1122
3
+ metadata.gz: 3fc25e98798f5e17ea43d7d3a0c23f0803dc5ff13e7182464e4ce285414502d9
4
+ data.tar.gz: 798e995b0fe8a6669d959c12bc3675acf2a15d15c3b6cadc8503d072b102e99e
5
5
  SHA512:
6
- metadata.gz: 7169e96f6ba961b134a96205f43bd023c6ed6a6a1287d57e73e3e78b34fabbb011f19059beb1b27550611a87ac901b51b014a2ef51fdfce99f6d5fd544c21171
7
- data.tar.gz: a777f05ee638aa1cb76c74edfcf76c1d8d0aa7b1f8cb405ccd4cfe6c34294c41949144ae47b581d26194b31e02759db0b8a180ac4e99bb8e0da211f49d7dd742
6
+ metadata.gz: d5d8314c5a5c895721d54cbc2f2154313d766d54f405ce867ff74b9396a9d81e1f7afc290c6ad88cfd60dd248dda112331247960eb2f8958489ee1da1c1ae07a
7
+ data.tar.gz: 07bde36a96d3f93de56be65cb0773192b469f865ebb8867e8cf1333f5fd8001f098affaea3e62cfefdbf64b86dc066429d64eb74bbf04f73f0c61a763285de0d
@@ -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: failed to parse channel file: #{path}"
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
 
@@ -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
@@ -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.write(path, token)
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' => 'ghcr.io/lax/castcaster-nginx',
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' => 'ghcr.io/lax/castcaster-webui',
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' => 'ghcr.io/lax/castcaster-ffmpeg',
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: 'ghcr.io/lax/castcaster-nginx',
38
- webui_image: 'ghcr.io/lax/castcaster-webui',
39
- ffmpeg_image: 'ghcr.io/lax/castcaster-ffmpeg',
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' => 'ghcr.io/lax/castcaster-nginx',
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' => 'ghcr.io/lax/castcaster-webui',
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'}
@@ -1,3 +1,4 @@
1
+ require 'erb'
1
2
  require_relative 'deploy/ffmpeg_services'
2
3
  require_relative 'deploy/compose'
3
4
  require_relative 'deploy/swarm'
@@ -1,7 +1,7 @@
1
1
  module CastCaster
2
2
  module Engines
3
- class NginxRTMP < Base
4
- IMAGE = 'ghcr.io/lax/castcaster-nginx'
3
+ class NginxRTMP < Base
4
+ IMAGE = CastCaster::IMAGES['nginx']
5
5
 
6
6
  def config_file
7
7
  File.join(project_dir, 'nginx', 'nginx.conf')
@@ -1,3 +1,3 @@
1
1
  module CastCaster
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  end
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: 8080
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: 8080
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
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castcaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax