Improve error handling in db_pull task
This commit is contained in:
@@ -15,8 +15,12 @@ defmodule Mix.Tasks.MusicLibrary.DbPull do
|
|||||||
remote_db = "/mnt/music_library/music_library_prod.db"
|
remote_db = "/mnt/music_library/music_library_prod.db"
|
||||||
local_db = "data/music_library_prod_#{DateTime.to_unix(current_time)}.db"
|
local_db = "data/music_library_prod_#{DateTime.to_unix(current_time)}.db"
|
||||||
|
|
||||||
System.cmd("flyctl", ["ssh", "sftp", "get", remote_db, local_db], into: IO.stream())
|
case System.cmd("flyctl", ["ssh", "sftp", "get", remote_db, local_db], into: IO.stream()) do
|
||||||
|
{_stream, 1} ->
|
||||||
|
IO.puts("Failed to pull the database")
|
||||||
|
System.halt(1)
|
||||||
|
|
||||||
|
{_stream, 0} ->
|
||||||
IO.puts("Database pulled successfully")
|
IO.puts("Database pulled successfully")
|
||||||
|
|
||||||
IO.puts("Restoring as local dev database")
|
IO.puts("Restoring as local dev database")
|
||||||
@@ -26,4 +30,5 @@ defmodule Mix.Tasks.MusicLibrary.DbPull do
|
|||||||
|
|
||||||
File.cp!(local_db, "data/music_library_dev.db")
|
File.cp!(local_db, "data/music_library_dev.db")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user