Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
419 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class MediaSyncingController < ApplicationController | ||
before_action :require_admin | ||
|
||
def create | ||
if Media.syncing? | ||
flash[:error] = t("error.syncing_in_progress") | ||
redirect_to setting_path | ||
else | ||
MediaSyncJob.perform_later | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
class MediaListener | ||
include Singleton | ||
|
||
SERVICE_PATH = File.join(Rails.root, "lib", "daemons", "media_listener_service") | ||
class Config | ||
DEFAULTS = { | ||
service_name: "media_listener_service", | ||
pid_dir: File.join(Rails.root, "tmp", "pids") | ||
} | ||
|
||
attr_accessor :service_name, :pid_dir | ||
|
||
def initialize | ||
DEFAULTS.each do |key, value| | ||
send("#{key}=", value) | ||
end | ||
end | ||
end | ||
|
||
class << self | ||
delegate :start, :stop, :running?, to: :instance | ||
|
||
def config | ||
yield instance.config | ||
end | ||
end | ||
|
||
attr_reader :config | ||
|
||
def initialize | ||
@config = Config.new | ||
end | ||
|
||
def start | ||
run("start") | ||
end | ||
|
||
def stop | ||
run("stop") | ||
end | ||
|
||
def running? | ||
pid_file_path = Daemons::PidFile.find_files(@config.pid_dir, @config.service_name).first | ||
return false unless pid_file_path.present? | ||
|
||
pid_file = Daemons::PidFile.existing(pid_file_path) | ||
Daemons::Pid.running?(pid_file.pid) | ||
end | ||
|
||
private | ||
|
||
def run(command) | ||
system "bundle exec #{SERVICE_PATH} #{command} -d #{@config.pid_dir} -n #{@config.service_name}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div id="turbo-media-syncing-button"> | ||
<% if syncing %> | ||
<%= button_to( | ||
t("label.syncing"), | ||
false, | ||
class: "c-button c-button--secondary", | ||
data: {test_id: "media_sync_button"}, | ||
disabled: true | ||
) %> | ||
<% else %> | ||
<%= button_to( | ||
t("label.sync"), | ||
media_syncing_path, | ||
class: "c-button c-button--secondary", | ||
data: { | ||
test_id: "media_sync_button", | ||
turbo_submits_with: t("label.syncing") | ||
} | ||
) %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= turbo_stream.replace "turbo-media-syncing-button", partial: "media_syncing/button", locals: {syncing: syncing} %> | ||
<% unless syncing %> | ||
<%= render_flash(message: t("text.sync_completed")) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render partial: "media_syncing/syncing", locals: { syncing: true } %> |
Oops, something went wrong.