Use Mix.Shell.IO helpers to print msgs to the terminal
This commit is contained in:
@@ -11,7 +11,7 @@ defmodule Mix.Tasks.MusicLibrary.Prod.DbMigrate do
|
|||||||
|
|
||||||
@impl Mix.Task
|
@impl Mix.Task
|
||||||
def run(_args) do
|
def run(_args) do
|
||||||
IO.puts("Running migrations on production database")
|
Mix.Shell.IO.info("Running migrations on production database")
|
||||||
|
|
||||||
fly_ssh("bin/migrate")
|
fly_ssh("bin/migrate")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ defmodule Mix.Tasks.MusicLibrary.Prod.DbPull do
|
|||||||
|
|
||||||
@impl Mix.Task
|
@impl Mix.Task
|
||||||
def run(_args) do
|
def run(_args) do
|
||||||
IO.puts("Pulling the latest database from the production server")
|
Mix.Shell.IO.info("Pulling the latest database from the production server")
|
||||||
|
|
||||||
current_time = DateTime.utc_now()
|
current_time = DateTime.utc_now()
|
||||||
remote_db = "/mnt/music_library/music_library_prod.db"
|
remote_db = "/mnt/music_library/music_library_prod.db"
|
||||||
@@ -18,13 +18,13 @@ defmodule Mix.Tasks.MusicLibrary.Prod.DbPull do
|
|||||||
|
|
||||||
case fly_sftp_get(remote_db, local_db) do
|
case fly_sftp_get(remote_db, local_db) do
|
||||||
{_stream, 1} ->
|
{_stream, 1} ->
|
||||||
IO.puts("Failed to pull the database")
|
Mix.Shell.IO.error("Failed to pull the database")
|
||||||
System.halt(1)
|
System.halt(1)
|
||||||
|
|
||||||
{_stream, 0} ->
|
{_stream, 0} ->
|
||||||
IO.puts("Database pulled successfully")
|
Mix.Shell.IO.info("Database pulled successfully")
|
||||||
|
|
||||||
IO.puts("Restoring as local dev database")
|
Mix.Shell.IO.info("Restoring as local dev database")
|
||||||
|
|
||||||
Path.wildcard("data/music_library_dev.db*")
|
Path.wildcard("data/music_library_dev.db*")
|
||||||
|> Enum.each(&File.rm!/1)
|
|> Enum.each(&File.rm!/1)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ defmodule Mix.Tasks.MusicLibrary.Prod.DbVacuum do
|
|||||||
|
|
||||||
@impl Mix.Task
|
@impl Mix.Task
|
||||||
def run(_args) do
|
def run(_args) do
|
||||||
IO.puts("Running VACUUM on the production database")
|
Mix.Shell.IO.info("Running VACUUM on the production database")
|
||||||
|
|
||||||
command = ~s(bin/music_library rpc 'MusicLibrary.Repo.query\("VACUUM"\)')
|
command = ~s(bin/music_library rpc 'MusicLibrary.Repo.query\("VACUUM"\)')
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ defmodule Mix.Tasks.MusicLibrary.Prod.Helpers do
|
|||||||
if flyctl_installed?() do
|
if flyctl_installed?() do
|
||||||
System.cmd("flyctl", ["ssh", "console", "--command", command], into: IO.stream())
|
System.cmd("flyctl", ["ssh", "console", "--command", command], into: IO.stream())
|
||||||
else
|
else
|
||||||
IO.puts("Please install flyctl first")
|
Mix.Shell.IO.error("Please install flyctl first")
|
||||||
System.halt(1)
|
System.halt(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -12,7 +12,7 @@ defmodule Mix.Tasks.MusicLibrary.Prod.Helpers do
|
|||||||
if flyctl_installed?() do
|
if flyctl_installed?() do
|
||||||
System.cmd("flyctl", ["ssh", "sftp", "get", remote_path, local_path], into: IO.stream())
|
System.cmd("flyctl", ["ssh", "sftp", "get", remote_path, local_path], into: IO.stream())
|
||||||
else
|
else
|
||||||
IO.puts("Please install flyctl first")
|
Mix.Shell.IO.error("Please install flyctl first")
|
||||||
System.halt(1)
|
System.halt(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user