Skip to content

Commit

Permalink
chore: adapt to node binary renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bochaco committed Dec 11, 2024
1 parent 194d165 commit cd75900
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
15 changes: 5 additions & 10 deletions formica.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,19 @@ RUN apt-get update -y \
COPY --from=builder /usr/local/bin/safeup /app/

# Copy the node binary to the /app directory
COPY --from=builder /app/safenode /app/
RUN /app/safenode --version
COPY --from=builder /app/antnode /app/
RUN /app/antnode --version

# Set any required env variables
# Set default port numbers for node and its RPC API
# Set default port numbers for node and its metrics service
ENV NODE_PORT=12000
# RPC API usage is deprecated
ENV RPC_PORT=13000
ENV METRICS_PORT=14000

# This can be used to set the rewards address. The rewards address is the address
# This can be used to set the rewards address. This is the address
# that will receive the rewards for the node: --rewards-address <REWARDS_ADDRESS>
ENV REWARDS_ADDR_ARG=''

EXPOSE $NODE_PORT
# RPC API usage is deprecated
EXPOSE $RPC_PORT
EXPOSE $METRICS_PORT

# Temporary fix to use nginx since the node metrics server is exposed only at ip 127.0.0.1
Expand All @@ -48,9 +44,8 @@ RUN apt-get -y update && apt-get -y install nginx
# Run the node
CMD ["sh", "-c", \
"echo \"server { listen ${METRICS_PORT}; server_name localhost; location /metrics { proxy_pass http://127.0.0.1:9090/metrics; include /etc/nginx/proxy_params; } }\" > /etc/nginx/sites-available/default \
&& nginx && /app/safenode --home-network \
&& nginx && /app/antnode --home-network \
--port ${NODE_PORT} \
--rpc 0.0.0.0:${RPC_PORT} \
--metrics-server-port 9090 \
--root-dir /app/node_data \
--log-output-dest /app/node_data/logs \
Expand Down
4 changes: 2 additions & 2 deletions src/docker_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl DockerClient {
Cmd: Some(vec![
"sh".to_string(),
"-c".to_string(),
"tail -s 7 -f /app/node_data/logs/safenode.log".to_string(),
"tail -s 7 -f /app/node_data/logs/antnode.log".to_string(),
]),
Tty: Some(false),
};
Expand Down Expand Up @@ -357,7 +357,7 @@ impl DockerClient {
&self,
id: &ContainerId,
) -> Result<(Option<String>, Option<String>), DockerClientError> {
let cmd = "/app/safenode --version | grep -oE 'Autonomi Node v[0-9]+\\.[0-9]+\\.[0-9]+'"
let cmd = "/app/antnode --version | grep -oE 'Autonomi Node v[0-9]+\\.[0-9]+\\.[0-9]+'"
.to_string();
let (_, resp_str) = self
.exec_in_container(id, cmd, "get node bin version")
Expand Down
20 changes: 10 additions & 10 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ pub struct NodeMetric {
pub type Metrics = HashMap<String, Vec<NodeMetric>>;

// The number of Nanos in the node reward wallet.
pub const METRIC_KEY_BALANCE: &str = "sn_node_current_reward_wallet_balance";
pub const METRIC_KEY_BALANCE: &str = "ant_node_current_reward_wallet_balance";
// The store cost of the node.
pub const METRIC_KEY_STORE_COST: &str = "sn_networking_store_cost";
pub const METRIC_KEY_STORE_COST: &str = "ant_networking_store_cost";
// Memory used by the process in MegaBytes.
pub const METRIC_KEY_MEM_USED_MB: &str = "sn_networking_process_memory_used_mb";
pub const METRIC_KEY_MEM_USED_MB: &str = "ant_networking_process_memory_used_mb";
// The percentage of CPU used by the process. Value is from 0-100.
pub const METRIC_KEY_CPU_USEAGE: &str = "sn_networking_process_cpu_usage_percentage";
pub const METRIC_KEY_CPU_USEAGE: &str = "ant_networking_process_cpu_usage_percentage";
// The number of records stored locally.
pub const METRIC_KEY_RECORDS: &str = "sn_networking_records_stored";
pub const METRIC_KEY_RECORDS: &str = "ant_networking_records_stored";
// The number of records that we're responsible for. This is used to calculate the store cost.
pub const METRIC_KEY_RELEVANT_RECORDS: &str = "sn_networking_relevant_records";
pub const METRIC_KEY_RELEVANT_RECORDS: &str = "ant_networking_relevant_records";
// The number of peers that we are currently connected to.
pub const METRIC_KEY_CONNECTED_PEERS: &str = "sn_networking_connected_peers";
pub const METRIC_KEY_CONNECTED_PEERS: &str = "ant_networking_connected_peers";
// The total number of peers in our routing table.
pub const METRIC_KEY_PEERS_IN_RT: &str = "sn_networking_peers_in_routing_table";
pub const METRIC_KEY_PEERS_IN_RT: &str = "ant_networking_peers_in_routing_table";
// Number of peers that have shunned our node.
pub const METRIC_KEY_SHUNNED_COUNT: &str = "sn_networking_shunned_count_total";
pub const METRIC_KEY_SHUNNED_COUNT: &str = "ant_networking_shunned_count_total";
// The estimated number of nodes in the network calculated by the peers in our RT.
pub const METRIC_KEY_NET_SIZE: &str = "sn_networking_estimated_network_size";
pub const METRIC_KEY_NET_SIZE: &str = "ant_networking_estimated_network_size";

0 comments on commit cd75900

Please sign in to comment.