mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-17 13:07:32 +02:00
Make web server port configurable (#314)
* Make host and port for web server configurable * Add webadmin host and port to config file * Use current host and port in web frontend * Remove envoy and frontend from docker compose * Remove envoy * Remove unused postgres docker volume
This commit is contained in:
parent
70f6766d6b
commit
6f8e556bcf
9 changed files with 39 additions and 175 deletions
|
|
@ -28,6 +28,10 @@ rpc_port=8774
|
|||
rpc_host=0.0.0.0
|
||||
rpc_port=8994
|
||||
|
||||
[webadmin]
|
||||
host=0.0.0.0
|
||||
port=5000
|
||||
|
||||
[postgresql]
|
||||
host=db
|
||||
database=squeakserver
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ services:
|
|||
- lnd_other_dir:/root/.lnd
|
||||
- ./config.ini:/app/config.ini
|
||||
- sqk_other_dir:/root/.sqk
|
||||
ports:
|
||||
- 5001:5000
|
||||
links:
|
||||
- "btcd:btcd"
|
||||
- "lnd_other:lnd"
|
||||
|
|
@ -93,54 +95,6 @@ services:
|
|||
- net.ipv6.conf.all.disable_ipv6=0
|
||||
entrypoint: ["./start-sqkserver.sh"]
|
||||
|
||||
envoy:
|
||||
image: envoy
|
||||
container_name: envoy
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: docker/envoy/Dockerfile
|
||||
ports:
|
||||
- 8080:8080
|
||||
links:
|
||||
- "sqkserver:sqkserver"
|
||||
environment:
|
||||
- SERVICE_NAME=sqkserver
|
||||
|
||||
envoy_other:
|
||||
image: envoy_other
|
||||
container_name: envoy_other
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: docker/envoy/Dockerfile
|
||||
ports:
|
||||
- 8090:8080
|
||||
links:
|
||||
- "sqkserver_other:sqkserver_other"
|
||||
environment:
|
||||
- SERVICE_NAME=sqkserver_other
|
||||
|
||||
frontend:
|
||||
image: frontend
|
||||
container_name: frontend
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: docker/frontend/Dockerfile
|
||||
args:
|
||||
- PORT=8080
|
||||
ports:
|
||||
- 8081:8081
|
||||
|
||||
frontend_other:
|
||||
image: frontend_other
|
||||
container_name: frontend_other
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: docker/frontend/Dockerfile
|
||||
args:
|
||||
- PORT=8090
|
||||
ports:
|
||||
- 8091:8081
|
||||
|
||||
volumes:
|
||||
bitcoin:
|
||||
driver: local
|
||||
|
|
@ -162,6 +116,3 @@ volumes:
|
|||
|
||||
sqk_other_dir:
|
||||
driver: local
|
||||
|
||||
postgres_dir:
|
||||
driver: local
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# Copyright 2018 Google LLC
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
|
||||
FROM envoyproxy/envoy:v1.15.0
|
||||
|
||||
#COPY "frontend/envoy.yaml" /etc/envoy/envoy.yaml
|
||||
|
||||
#CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml -l trace --log-path /tmp/envoy_info.log
|
||||
|
||||
|
||||
|
||||
COPY "frontend/envoy.yaml" /tmpl/envoy.yaml.tmpl
|
||||
COPY docker/envoy/docker-entrypoint.sh /
|
||||
|
||||
RUN chmod 500 /docker-entrypoint.sh
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install gettext -y
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "Generating envoy.yaml config file..."
|
||||
cat /tmpl/envoy.yaml.tmpl | envsubst \$ENVOY_LB_ALG,\$SERVICE_NAME > /etc/envoy.yaml
|
||||
|
||||
echo "Starting Envoy..."
|
||||
/usr/local/bin/envoy -c /etc/envoy.yaml
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
admin:
|
||||
access_log_path: /tmp/admin_access.log
|
||||
address:
|
||||
socket_address: { address: 0.0.0.0, port_value: 9901 }
|
||||
|
||||
static_resources:
|
||||
listeners:
|
||||
- name: listener_0
|
||||
address:
|
||||
socket_address: { address: 0.0.0.0, port_value: 8080 }
|
||||
filter_chains:
|
||||
- filters:
|
||||
- name: envoy.filters.network.http_connection_manager
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
|
||||
codec_type: auto
|
||||
stat_prefix: ingress_http
|
||||
route_config:
|
||||
name: local_route
|
||||
virtual_hosts:
|
||||
- name: local_service
|
||||
domains: ["*"]
|
||||
routes:
|
||||
- match: { prefix: "/" }
|
||||
route:
|
||||
cluster: squeak_admin_service
|
||||
max_grpc_timeout: 0s
|
||||
cors:
|
||||
allow_origin_string_match:
|
||||
- prefix: "*"
|
||||
allow_methods: GET, PUT, DELETE, POST, OPTIONS
|
||||
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
|
||||
max_age: "1728000"
|
||||
expose_headers: custom-header-1,grpc-status,grpc-message
|
||||
http_filters:
|
||||
- name: envoy.filters.http.grpc_web
|
||||
- name: envoy.filters.http.cors
|
||||
- name: envoy.filters.http.router
|
||||
clusters:
|
||||
- name: squeak_admin_service
|
||||
connect_timeout: 0.25s
|
||||
type: logical_dns
|
||||
http2_protocol_options: {}
|
||||
lb_policy: round_robin
|
||||
# win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below
|
||||
load_assignment:
|
||||
cluster_name: cluster_0
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${SERVICE_NAME}
|
||||
port_value: 8994
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
import { client } from "../squeakclient/squeakclient"
|
||||
|
||||
import {
|
||||
GetInfoRequest,
|
||||
WalletBalanceRequest,
|
||||
|
|
@ -79,8 +77,14 @@ import {
|
|||
} from "../proto/squeak_admin_pb"
|
||||
|
||||
|
||||
export let web_host_port = 'http://' + window.location.hostname + ':' + window.location.port;
|
||||
|
||||
console.log("web_host_port:");
|
||||
console.log(web_host_port);
|
||||
|
||||
|
||||
function makeRequest(route, request, handleResponse) {
|
||||
fetch('http://localhost:5000/' + route, {
|
||||
fetch(web_host_port + '/' + route, {
|
||||
method: 'post',
|
||||
body: request.serializeBinary()
|
||||
}).then(function(response) {
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import { SqueakAdminClient } from "../proto/squeak_admin_grpc_web_pb"
|
||||
|
||||
const PORT = process.env.REACT_APP_PORT;
|
||||
|
||||
console.log("port:");
|
||||
console.log(PORT);
|
||||
|
||||
const rpc_port = PORT ? PORT : 8080
|
||||
|
||||
console.log("rpc_port:");
|
||||
console.log(rpc_port);
|
||||
|
||||
export let client = new SqueakAdminClient('http://' + window.location.hostname + ':' + rpc_port)
|
||||
|
|
@ -295,10 +295,17 @@ def create_app(handler):
|
|||
return app
|
||||
|
||||
|
||||
def run_app(handler):
|
||||
app = create_app(handler)
|
||||
app.run(
|
||||
host="0.0.0.0",
|
||||
port=5000,
|
||||
debug=False,
|
||||
)
|
||||
class SqueakAdminWebServer():
|
||||
|
||||
def __init__(self, host, port, handler):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.handler = handler
|
||||
self.app = create_app(handler)
|
||||
|
||||
def serve(self):
|
||||
self.app.run(
|
||||
self.host,
|
||||
self.port,
|
||||
debug=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from squeak.params import SelectParams
|
|||
|
||||
from squeakserver.admin.squeak_admin_server_handler import SqueakAdminServerHandler
|
||||
from squeakserver.admin.squeak_admin_server_servicer import SqueakAdminServerServicer
|
||||
from squeakserver.admin.squeak_admin_web_service import SqueakAdminWebServer
|
||||
from squeakserver.blockchain.bitcoin_blockchain_client import BitcoinBlockchainClient
|
||||
from squeakserver.common.lnd_lightning_client import LNDLightningClient
|
||||
from squeakserver.db.db_engine import get_postgres_engine, get_sqlite_engine
|
||||
|
|
@ -18,7 +19,6 @@ from squeakserver.node.squeak_node import SqueakNode
|
|||
from squeakserver.server.lightning_address import LightningAddressHostPort
|
||||
from squeakserver.server.squeak_server_handler import SqueakServerHandler
|
||||
from squeakserver.server.squeak_server_servicer import SqueakServerServicer
|
||||
from squeakserver.admin.squeak_admin_web_service import run_app
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -61,9 +61,12 @@ def load_admin_rpc_server(config, handler) -> SqueakAdminServerServicer:
|
|||
)
|
||||
|
||||
|
||||
def load_admin_web_server(config, handler):
|
||||
# TODO
|
||||
pass
|
||||
def load_admin_web_server(config, handler) -> SqueakAdminWebServer:
|
||||
return SqueakAdminWebServer(
|
||||
config["webadmin"]["host"],
|
||||
config["webadmin"]["port"],
|
||||
handler,
|
||||
)
|
||||
|
||||
|
||||
def load_network(config):
|
||||
|
|
@ -149,11 +152,11 @@ def start_admin_rpc_server(rpc_server):
|
|||
thread.start()
|
||||
|
||||
|
||||
def start_admin_web_server(handler):
|
||||
def start_admin_web_server(admin_web_server):
|
||||
logger.info("Calling start_admin_web_server...")
|
||||
thread = threading.Thread(
|
||||
target=run_app,
|
||||
args=(handler,),
|
||||
target=admin_web_server.serve,
|
||||
args=(),
|
||||
)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
|
@ -248,7 +251,8 @@ def run_server(config):
|
|||
start_admin_rpc_server(admin_rpc_server)
|
||||
|
||||
# start admin web server
|
||||
start_admin_web_server(admin_handler)
|
||||
admin_web_server = load_admin_web_server(config, admin_handler)
|
||||
start_admin_web_server(admin_web_server)
|
||||
|
||||
# start rpc server
|
||||
handler = load_handler(squeak_node)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue