@rpcbase/server 0.69.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin.js
CHANGED
|
@@ -6,16 +6,17 @@ require("dotenv").config({path: path.join(__dirname, "./.env")})
|
|
|
6
6
|
const yargs = require("yargs/yargs")
|
|
7
7
|
const {hideBin} = require("yargs/helpers")
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const start_server_infrastructure = require("./cli/start_server_infrastructure")
|
|
10
10
|
const build_server = require("./cli/build_server")
|
|
11
11
|
const run_agent = require("./cli/run_agent")
|
|
12
12
|
|
|
13
13
|
let is_command = false
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
const args = yargs(hideBin(process.argv))
|
|
16
|
-
.command("start", "
|
|
17
|
+
.command("start", "runs server/infrastructure", () => {}, (args) => {
|
|
17
18
|
is_command = true
|
|
18
|
-
|
|
19
|
+
start_server_infrastructure(args)
|
|
19
20
|
})
|
|
20
21
|
.command("agent", "run the agent", () => {}, (args) => {
|
|
21
22
|
is_command = true
|
package/cli/run_native.js
CHANGED
|
@@ -3,14 +3,14 @@ const {spawn} = require("child_process")
|
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const fs = require("fs")
|
|
5
5
|
|
|
6
|
+
const colors = require("picocolors")
|
|
7
|
+
const validator = require("validator")
|
|
6
8
|
const dotenv = require("dotenv")
|
|
7
9
|
const mkdirp = require("mkdirp")
|
|
8
10
|
|
|
9
|
-
// TODO: verify mongod and redis-sever executables are present
|
|
11
|
+
// TODO: verify mongod and redis-sever and elasticsearch executables are present
|
|
10
12
|
// and have the right version
|
|
11
13
|
|
|
12
|
-
// "redis-server", "/usr/local/etc/redis/redis.conf", "--port", $WORKER_QUEUE_PORT
|
|
13
|
-
|
|
14
14
|
// load env
|
|
15
15
|
const get_env = () => {
|
|
16
16
|
const env_path = path.join(process.cwd(), "./.env")
|
|
@@ -29,14 +29,17 @@ const init_processes = () => {
|
|
|
29
29
|
const db_logs_path = path.join(process.cwd(), "../infrastructure/data/database/log/")
|
|
30
30
|
|
|
31
31
|
const session_store_dir = path.join(process.cwd(), "../infrastructure/data/session-store/data")
|
|
32
|
+
const worker_queue_dir = path.join(process.cwd(), "../infrastructure/data/worker-queue/data")
|
|
32
33
|
|
|
33
34
|
// TODO: add a redis cache
|
|
34
35
|
const processes = [
|
|
35
36
|
// web server
|
|
36
37
|
// TODO: do not use yarn dev server command
|
|
38
|
+
// use command: rb-server dev
|
|
37
39
|
{
|
|
38
40
|
name: "server",
|
|
39
41
|
dirs: [],
|
|
42
|
+
// yarn dev
|
|
40
43
|
cmd: ["yarn", ["dev"]]
|
|
41
44
|
},
|
|
42
45
|
// mongodb database
|
|
@@ -54,6 +57,7 @@ const init_processes = () => {
|
|
|
54
57
|
"--replSet", "rs0"
|
|
55
58
|
]]
|
|
56
59
|
},
|
|
60
|
+
// session-store
|
|
57
61
|
{
|
|
58
62
|
name: "session-store",
|
|
59
63
|
dirs: [
|
|
@@ -65,8 +69,41 @@ const init_processes = () => {
|
|
|
65
69
|
"--port", env.SESSION_STORE_PORT,
|
|
66
70
|
]]
|
|
67
71
|
},
|
|
72
|
+
// worker-queue
|
|
73
|
+
{
|
|
74
|
+
name: "worker-queue",
|
|
75
|
+
dirs: [
|
|
76
|
+
worker_queue_dir,
|
|
77
|
+
],
|
|
78
|
+
cmd: ["redis-server", [
|
|
79
|
+
path.join(infrastructure_conf_dir, "./redis/redis.conf"),
|
|
80
|
+
"--dir", worker_queue_dir,
|
|
81
|
+
"--port", env.WORKER_QUEUE_PORT,
|
|
82
|
+
]]
|
|
83
|
+
},
|
|
68
84
|
]
|
|
69
85
|
|
|
86
|
+
// add search-index elasticsearch if port is defined
|
|
87
|
+
if (env.SEARCH_INDEX_PORT && validator.isPort(env.SEARCH_INDEX_PORT)) {
|
|
88
|
+
const data_dir = path.join(process.cwd(), "../infrastructure/data/search-index/data")
|
|
89
|
+
const logs_dir = path.join(process.cwd(), "../infrastructure/data/search-index/logs")
|
|
90
|
+
processes.push({
|
|
91
|
+
name: "search-index",
|
|
92
|
+
dirs: [
|
|
93
|
+
data_dir,
|
|
94
|
+
logs_dir,
|
|
95
|
+
],
|
|
96
|
+
cmd: ["elasticsearch", [
|
|
97
|
+
"-s",
|
|
98
|
+
"-E", `path.logs=${logs_dir}`,
|
|
99
|
+
"-E", `http.port=${env.SEARCH_INDEX_PORT}`,
|
|
100
|
+
"-E", `path.data=${data_dir}`,
|
|
101
|
+
"-E", "discovery.type=single-node",
|
|
102
|
+
"-E", "ingest.geoip.downloader.enabled=false",
|
|
103
|
+
]]
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
70
107
|
// create missing directories
|
|
71
108
|
processes.forEach((item) => {
|
|
72
109
|
item.dirs.forEach((dir) => {
|
|
@@ -91,7 +128,7 @@ const run_native = (infrastructure_dir, proj_prefix) => {
|
|
|
91
128
|
const ps = spawn(item.cmd[0], item.cmd[1], {env: {...process.env, CONTAINER_MODE: "native"}})
|
|
92
129
|
|
|
93
130
|
ps.stdout.on("data", (data) => {
|
|
94
|
-
process.stdout.write(`${item.name}: ${data.toString()}`)
|
|
131
|
+
process.stdout.write(`${colors.green(item.name)}: ${data.toString()}`)
|
|
95
132
|
})
|
|
96
133
|
|
|
97
134
|
ps.stderr.on("data", (data) => {
|
|
File without changes
|
package/index.js
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# ======================== Elasticsearch Configuration =========================
|
|
2
|
+
#
|
|
3
|
+
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
|
|
4
|
+
# Before you set out to tweak and tune the configuration, make sure you
|
|
5
|
+
# understand what are you trying to accomplish and the consequences.
|
|
6
|
+
#
|
|
7
|
+
# The primary way of configuring a node is via this file. This template lists
|
|
8
|
+
# the most important settings you may want to configure for a production cluster.
|
|
9
|
+
#
|
|
10
|
+
# Please consult the documentation for further information on configuration options:
|
|
11
|
+
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
|
|
12
|
+
#
|
|
13
|
+
# ---------------------------------- Cluster -----------------------------------
|
|
14
|
+
#
|
|
15
|
+
# Use a descriptive name for your cluster:
|
|
16
|
+
#
|
|
17
|
+
#cluster.name: my-application
|
|
18
|
+
#
|
|
19
|
+
# ------------------------------------ Node ------------------------------------
|
|
20
|
+
#
|
|
21
|
+
# Use a descriptive name for the node:
|
|
22
|
+
#
|
|
23
|
+
#node.name: node-1
|
|
24
|
+
#
|
|
25
|
+
# Add custom attributes to the node:
|
|
26
|
+
#
|
|
27
|
+
#node.attr.rack: r1
|
|
28
|
+
#
|
|
29
|
+
# ----------------------------------- Paths ------------------------------------
|
|
30
|
+
#
|
|
31
|
+
# Path to directory where to store the data (separate multiple locations by comma):
|
|
32
|
+
#
|
|
33
|
+
@path.data@
|
|
34
|
+
#
|
|
35
|
+
# Path to log files:
|
|
36
|
+
#
|
|
37
|
+
@path.logs@
|
|
38
|
+
#
|
|
39
|
+
# ----------------------------------- Memory -----------------------------------
|
|
40
|
+
#
|
|
41
|
+
# Lock the memory on startup:
|
|
42
|
+
#
|
|
43
|
+
#bootstrap.memory_lock: true
|
|
44
|
+
#
|
|
45
|
+
# Make sure that the heap size is set to about half the memory available
|
|
46
|
+
# on the system and that the owner of the process is allowed to use this
|
|
47
|
+
# limit.
|
|
48
|
+
#
|
|
49
|
+
# Elasticsearch performs poorly when the system is swapping the memory.
|
|
50
|
+
#
|
|
51
|
+
# ---------------------------------- Network -----------------------------------
|
|
52
|
+
#
|
|
53
|
+
# By default Elasticsearch is only accessible on localhost. Set a different
|
|
54
|
+
# address here to expose this node on the network:
|
|
55
|
+
#
|
|
56
|
+
#network.host: 192.168.0.1
|
|
57
|
+
#
|
|
58
|
+
# By default Elasticsearch listens for HTTP traffic on the first free port it
|
|
59
|
+
# finds starting at 9200. Set a specific HTTP port here:
|
|
60
|
+
#
|
|
61
|
+
#http.port: 9200
|
|
62
|
+
#
|
|
63
|
+
# For more information, consult the network module documentation.
|
|
64
|
+
#
|
|
65
|
+
# --------------------------------- Discovery ----------------------------------
|
|
66
|
+
#
|
|
67
|
+
# Pass an initial list of hosts to perform discovery when this node is started:
|
|
68
|
+
# The default list of hosts is ["127.0.0.1", "[::1]"]
|
|
69
|
+
#
|
|
70
|
+
#discovery.seed_hosts: ["host1", "host2"]
|
|
71
|
+
#
|
|
72
|
+
# Bootstrap the cluster using an initial set of master-eligible nodes:
|
|
73
|
+
#
|
|
74
|
+
#cluster.initial_master_nodes: ["node-1", "node-2"]
|
|
75
|
+
#
|
|
76
|
+
# For more information, consult the discovery and cluster formation module documentation.
|
|
77
|
+
#
|
|
78
|
+
# --------------------------------- Readiness ----------------------------------
|
|
79
|
+
#
|
|
80
|
+
# Enable an unauthenticated TCP readiness endpoint on localhost
|
|
81
|
+
#
|
|
82
|
+
#readiness.port: 9399
|
|
83
|
+
#
|
|
84
|
+
# ---------------------------------- Various -----------------------------------
|
|
85
|
+
#
|
|
86
|
+
# Allow wildcard deletion of indices:
|
|
87
|
+
#
|
|
88
|
+
#action.destructive_requires_name: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@rpcbase/agent": "0.
|
|
13
|
+
"@rpcbase/agent": "0.8.0",
|
|
14
14
|
"body-parser": "1.20.0",
|
|
15
15
|
"connect-redis": "6.1.3",
|
|
16
16
|
"cors": "2.8.5",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"express": "4.18.1",
|
|
20
20
|
"express-session": "1.17.3",
|
|
21
21
|
"glob": "8.0.3",
|
|
22
|
-
"mongoose": "6.3.
|
|
22
|
+
"mongoose": "6.3.6",
|
|
23
|
+
"picocolors": "1.0.0",
|
|
23
24
|
"postmark": "3.0.11",
|
|
24
25
|
"redis": "4.1.0",
|
|
25
26
|
"validator": "13.7.0",
|