Skip to content

Commit

Permalink
added sistem check
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Ghio <[email protected]>
  • Loading branch information
shinnokdisengir committed Oct 2, 2024
1 parent d207ed0 commit d99cccf
Show file tree
Hide file tree
Showing 9 changed files with 1,903 additions and 75 deletions.
21 changes: 21 additions & 0 deletions tools/astarte_dev_tool/config/config.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Config

config :logger, :console,
format: {PrettyLog.LogfmtFormatter, :format},
metadata: [:realm, :datacenter, :replication_factor, :module, :function, :tag]

# Configure your database
config :astarte_dev_tool, Astarte.DataAccess.Repo,
# Overrides the default type `bigserial` used for version attribute in schema migration
migration_primary_key: [name: :id, type: :binary_id],
contact_points: [System.get_env("CASSANDRA_DB_HOST") || "localhost"],
keyspace: "astarte",
port: System.get_env("CASSANDRA_DB_PORT") || 9042,
# Waiting time in milliseconds for the database connection
sync_connect: 5000,
log: :info,
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10

config :astarte_dev_tool, ecto_repos: [Astarte.DataAccess.Repo]
54 changes: 54 additions & 0 deletions tools/astarte_dev_tool/lib/commands/system/check.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# This file is part of Astarte.
#
# Copyright 2024 SECO Mind Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

defmodule AstarteDevTool.Commands.System.Check do
@moduledoc false
require Logger
alias AstarteDevTool.Utilities.System, as: SystemUtilities

@astarte_services [
"astarte-dashboard",
"astarte-appengine-api",
"astarte-housekeeping",
"astarte-housekeeping-api",
"astarte-grafana",
"astarte-realm-management",
"astarte-realm-management-api",
"astarte-data-updater-plant",
"astarte-trigger-engine",
"astarte-pairing",
"astarte-pairing-api",
"vernemq",
"scylla",
"traefik",
"rabbitmq",
"cfssl"
]

def exec(path) do
case SystemUtilities.system_status(path) do
{:ok, list} ->
current_list = list |> Enum.map(fn %{"name" => name} -> name end) |> MapSet.new()

case Enum.filter(@astarte_services, &(not MapSet.member?(current_list, &1))) do
[] -> :ok
rest -> {:error, rest}
end
end
end
end
4 changes: 2 additions & 2 deletions tools/astarte_dev_tool/lib/commands/system/watch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ defmodule AstarteDevTool.Commands.System.Watch do
@moduledoc false
require Logger
alias AstarteDevTool.Constants.System, as: Constants
alias AstarteDevTool.Utilities.Process, as: AstarteProcess
alias AstarteDevTool.Utilities.Process, as: ProcessUtilities

def exec(path) do
case AstarteProcess.check_process(Constants.command(), Constants.command_watch_args(), path) do
case ProcessUtilities.process_check(Constants.command(), Constants.command_watch_args(), path) do
{:ok, pid} when not is_nil(pid) -> kill_zombie_process(pid)
_ -> :ok
end
Expand Down
Loading

0 comments on commit d99cccf

Please sign in to comment.