Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "codechain-agent-hub"
name = "codechain-dashboard-server"
version = "0.1.0"
authors = ["CodeChain Team <codechain@kodebox.io>"]

Expand Down
36 changes: 18 additions & 18 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
CodeChain Agent Hub
====================
CodeChain Dashboard Server
==========================

[![Join the chat at https://gitter.im/CodeChain-io/codechain-agent-hub](https://badges.gitter.im/CodeChain-io/codechain-agent-hub.svg)](https://gitter.im/CodeChain-io/codechain-agent-hub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

CodeChain Agent Hub is a server which collects many CodeChain node's information(best block, pending transactions, log, ...). Also, CodeChain Agent Hub serves collected data to CodeChain Dashboard.
CodeChain Dashboard Server is a server which collects many CodeChain node's information(best block, pending transactions, log, ...). Also, CodeChain Dashboard Server serves collected data to CodeChain Dashboard.

Install
--------

You should set up a rust toolchain.

You can install codechain-agent-hub by running `cargo install`
You can install codechain-dashboard-server by running `cargo install`

Install Postgres and create schema
-----------------
Expand All @@ -33,15 +33,15 @@ generate-schema
Run
----

Just run `codechain-agent-hub` in your shell.
Just run `codechain-dashboard-server` in your shell.
To safely communicate with the Dashboard, please set the `PASSPHRASE` environment variable. The Dashboard program should use the same passphrase.
Also, you should set `NETWORK_ID` environment variable to print the network id in log messages.

When you are using the `PASSPHRASE` you should use SSL over the connection. If you don't use the SSL, the `PASSPHRASE` is open to the internet.

CodeChain Agent Hub will listen 3012 port to communicate with the Dashboard using JSON-RPC.
CodeChain Dashboard Server will listen 3012 port to communicate with the Dashboard using JSON-RPC.

CodeChain Agent Hub will listen 4012 port to communicate with the Agent using JSON-RPC.
CodeChain Dashboard Server will listen 4012 port to communicate with the Dashboard Client using JSON-RPC.

Alerts
-------
Expand All @@ -51,24 +51,24 @@ The server sends an alert via Slack and Email in situations where there likely i
## Email alerts
To use email alerts, the server needs the [Sendgird](https://sendgrid.com/) api key.
```
SENDGRID_API_KEY={api key} SENDGRID_TO={email address} codechain-agent-hub
SENDGRID_API_KEY={api key} SENDGRID_TO={email address} codechain-dashboard-server
```

## Slack alerts
The server uses [webhooks](https://api.slack.com/incoming-webhooks)
```
SLACK_HOOK_URL={web hook url} codechain-agent-hub
SLACK_HOOK_URL={web hook url} codechain-dashboard-server
```

Environmental Variables
------------------------

| NAME | DESCRIPTION |
| ------------------- | ---------------------------------------------------------------------------------------------------- |
| START_AT_CONNECT | If this variable is set, a CodeChain instance is started once an agent connects to the agent server. |
| NETWORK_ID | Network ID information that is used in error messages or logs. |
| SLACK_WEBHOOK_URL | Used to send alarms to Slack. |
| SENDGRID_TO | An email address to receive alarm emails. |
| SENDGRID_API_KEY | An API Key that is used to send alarms. |
| PASSPHRASE | A passphrase that is used to communicate with the Dashboard safely. |
| ENABLE_MEMORY_ALARM | When this variable is set, the Agent Server sends memory alarms. |
| NAME | DESCRIPTION |
| ------------------- | ------------------------------------------------------------------------------------------------------------------ |
| START_AT_CONNECT | If this variable is set, a CodeChain instance is started once a dashboard client connects to the dashboard server. |
| NETWORK_ID | Network ID information that is used in error messages or logs. |
| SLACK_WEBHOOK_URL | Used to send alarms to Slack. |
| SENDGRID_TO | An email address to receive alarm emails. |
| SENDGRID_API_KEY | An API Key that is used to send alarms. |
| PASSPHRASE | A passphrase that is used to communicate with the Dashboard safely. |
| ENABLE_MEMORY_ALARM | When this variable is set, the Dashboard Server sends memory alarms. |
6 changes: 3 additions & 3 deletions server/create_user_and_db.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE DATABASE "codechain-agent-hub";
CREATE USER "codechain-agent-hub" WITH ENCRYPTED PASSWORD 'preempt-entreat-bell-chanson';
GRANT ALL PRIVILEGES ON DATABASE "codechain-agent-hub" TO "codechain-agent-hub";
CREATE DATABASE "codechain-dashboard-server";
CREATE USER "codechain-dashboard-server" WITH ENCRYPTED PASSWORD 'preempt-entreat-bell-chanson';
GRANT ALL PRIVILEGES ON DATABASE "codechain-dashboard-server" TO "codechain-dashboard-server";
6 changes: 3 additions & 3 deletions server/src/bin/delete-all-table.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#[macro_use]
extern crate codechain_agent_hub as chub;
extern crate codechain_dashboard_server as dashboard_server;
extern crate postgres;
#[macro_use]
extern crate log;

use chub::logger_init;
use dashboard_server::logger_init;
use postgres::{Connection, TlsMode};

fn main() {
logger_init().expect("Logger should be initialized");

// FIXME: move to configuration file
let user = "codechain-agent-hub";
let user = "codechain-dashboard-server";
let password = "preempt-entreat-bell-chanson";
let conn_uri = format!("postgres://{}:{}@localhost", user, password);
let conn = Connection::connect(conn_uri, TlsMode::None).unwrap();
Expand Down
14 changes: 7 additions & 7 deletions server/src/bin/generate-schema.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#[macro_use]
extern crate codechain_agent_hub as chub;
extern crate codechain_dashboard_server as dashboard_server;
extern crate postgres;
#[macro_use]
extern crate log;

use chub::logger_init;
use dashboard_server::logger_init;
use postgres::{Connection, TlsMode};

fn main() {
logger_init().expect("Logger should be initialized");

// FIXME: move to configuration file
let user = "codechain-agent-hub";
let user = "codechain-dashboard-server";
let password = "preempt-entreat-bell-chanson";
let conn_uri = format!("postgres://{}:{}@localhost", user, password);
let conn = Connection::connect(conn_uri, TlsMode::None).unwrap();

create_agent_extra_schema(&conn);
create_client_extra_schema(&conn);
create_logs_schema(&conn);
create_peer_count_schema(&conn);
create_network_usage_schema(&conn);
}

fn create_agent_extra_schema(conn: &Connection) {
cinfo!("Create agent_extra table");
fn create_client_extra_schema(conn: &Connection) {
cinfo!("Create client_extra table");
conn.execute(
"CREATE TABLE IF NOT EXISTS agent_extra (
"CREATE TABLE IF NOT EXISTS client_extra (
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL UNIQUE,
prev_env VARCHAR NOT NULL,
Expand Down
6 changes: 3 additions & 3 deletions server/src/bin/refresh-materialized-view.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
extern crate codechain_agent_hub as chub;
extern crate codechain_dashboard_server as dashboard_server;
extern crate log;
extern crate postgres;

use chub::logger_init;
use dashboard_server::logger_init;
use postgres::{Connection, TlsMode};

fn main() {
logger_init().expect("Logger should be initialized");

// FIXME: move to configuration file
let user = "codechain-agent-hub";
let user = "codechain-dashboard-server";
let password = "preempt-entreat-bell-chanson";
let conn_uri = format!("postgres://{}:{}@localhost", user, password);
let conn = Connection::connect(conn_uri, TlsMode::None).unwrap();
Expand Down
Loading