split host and port in .env variables

This commit is contained in:
jerryfletcher21 2024-07-05 01:26:53 +02:00
parent 886956c5a9
commit 7b3c62e14f
No known key found for this signature in database
GPG Key ID: 6FA7713E574EDEC3
9 changed files with 54 additions and 24 deletions

View File

@ -11,14 +11,24 @@ MACAROON_PATH='data/chain/bitcoin/testnet/admin.macaroon'
LND_CERT_BASE64='LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNLVENDQWRDZ0F3SUJBZ0lRQ0VoeGpPZXY1bGQyVFNPTXhKalFvekFLQmdncWhrak9QUVFEQWpBNE1SOHcKSFFZRFZRUUtFeFpzYm1RZ1lYVjBiMmRsYm1WeVlYUmxaQ0JqWlhKME1SVXdFd1lEVlFRREV3d3dNakJtTVRnMQpZelkwTnpVd0hoY05Nakl3TWpBNE1UWXhOalV3V2hjTk1qTXdOREExTVRZeE5qVXdXakE0TVI4d0hRWURWUVFLCkV4WnNibVFnWVhWMGIyZGxibVZ5WVhSbFpDQmpaWEowTVJVd0V3WURWUVFERXd3d01qQm1NVGcxWXpZME56VXcKV1RBVEJnY3Foa2pPUFFJQkJnZ3Foa2pPUFFNQkJ3TkNBQVNJVWdkcVMrWFZKL3EzY0JZeWd6ZDc2endaanlmdQpLK3BzcWNYVkFyeGZjU2NXQ25jbXliNGRaMy9Lc3lLWlRaamlySDE3aEY0OGtIMlp5clRZSW9hZG80RzdNSUc0Ck1BNEdBMVVkRHdFQi93UUVBd0lDcERBVEJnTlZIU1VFRERBS0JnZ3JCZ0VGQlFjREFUQVBCZ05WSFJNQkFmOEUKQlRBREFRSC9NQjBHQTFVZERnUVdCQlEwWUJjZXdsd1BqYTJPRXFyTGxzZnJscEswUFRCaEJnTlZIUkVFV2pCWQpnZ3d3TWpCbU1UZzFZelkwTnpXQ0NXeHZZMkZzYUc5emRJSUVkVzVwZUlJS2RXNXBlSEJoWTJ0bGRJSUhZblZtClkyOXVib2NFZndBQUFZY1FBQUFBQUFBQUFBQUFBQUFBQUFBQUFZY0V3S2dRQW9jRUFBQUFBREFLQmdncWhrak8KUFFRREFnTkhBREJFQWlBd0dMY05qNXVZSkVwanhYR05OUnNFSzAwWmlSUUh2Qm50NHp6M0htWHBiZ0lnSWtvUQo3cHFvNGdWNGhiczdrSmt1bnk2bkxlNVg0ZzgxYjJQOW52ZnZ2bkk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K'
# base64 ~/.lnd/data/chain/bitcoin/testnet/admin.macaroon | tr -d '\n'
LND_MACAROON_BASE64='AgEDbG5kAvgBAwoQsyI+PK+fyb7F2UyTeZ4seRIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgMt90uD6v4truTadWCjlppoeJ4hZrL1SBb09Y+4WOiI0='
LND_GRPC_HOST='localhost'
LND_GRPC_PORT='10009'
# Auto unlock LND password. Only used in development docker-compose environment.
# It will fail starting up the node without it.
# To disable auto unlock, comment out 'wallet-unlock-password-file=/tmp/pwd' from 'docker/lnd/lnd.conf'
AUTO_UNLOCK_PWD='1234'
# CLN directory
CLN_DIR='/cln/testnet/'
CLN_GRPC_HOST='localhost:9999'
CLN_GRPC_HOLD_HOST='localhost:9998'
CLN_GRPC_HOST='localhost'
CLN_GRPC_PORT='9999'
CLN_GRPC_HOLD_HOST='localhost'
CLN_GRPC_HOLD_PORT='9998'
# Bitcoin Core Daemon RPC, used to validate addresses
BITCOIND_RPCURL = 'http://127.0.0.1:18332'
# mainnet: 8332, testnet: 18332, signet: 38332, regtest: 18443
BITCOIND_RPCHOST = '127.0.0.1'
BITCOIND_RPCPORT = '18332'
BITCOIND_RPCUSER = 'robodev'
BITCOIND_RPCPASSWORD = 'robodev'
@ -33,14 +43,9 @@ POSTGRES_PORT='5432'
USE_TOR=True
TOR_PROXY='127.0.0.1:9050'
# Auto unlock LND password. Only used in development docker-compose environment.
# It will fail starting up the node without it.
# To disable auto unlock, comment out 'wallet-unlock-password-file=/tmp/pwd' from 'docker/lnd/lnd.conf'
AUTO_UNLOCK_PWD='1234'
LND_GRPC_HOST='localhost:10009'
REDIS_URL='redis://localhost:6379/1'
REDIS_HOST="localhost"
REDIS_PORT="6379"
REDIS_DB_NUMBER="1"
# List of market price public APIs. If the currency is available in more than 1 API, will use median price.
MARKET_PRICE_APIS = https://blockchain.info/ticker, https://api.yadio.io/exrates/BTC, https://bitpay.com/rates/BTC, https://criptoya.com/api/btc

View File

@ -29,8 +29,12 @@ with open(os.path.join(CLN_DIR, "server.pem"), "rb") as f:
server_cert = f.read()
CLN_GRPC_HOST = config("CLN_GRPC_HOST", cast=str, default="localhost:9999")
CLN_GRPC_HOLD_HOST = config("CLN_GRPC_HOLD_HOST", cast=str, default="localhost:9998")
CLN_GRPC_HOST = \
str(config("CLN_GRPC_HOST", cast=str, default="localhost")) + \
":" + str(config("CLN_GRPC_PORT", cast=str, default="9999"))
CLN_GRPC_HOLD_HOST = \
str(config("CLN_GRPC_HOLD_HOST", cast=str, default="localhost")) + \
":" + str(config("CLN_GRPC_HOLD_PORT", cast=str, default="9998"))
DISABLE_ONCHAIN = config("DISABLE_ONCHAIN", cast=bool, default=True)
MAX_SWAP_AMOUNT = config("MAX_SWAP_AMOUNT", cast=int, default=500000)

View File

@ -42,7 +42,9 @@ try:
except Exception:
MACAROON = b64decode(config("LND_MACAROON_BASE64"))
LND_GRPC_HOST = config("LND_GRPC_HOST")
LND_GRPC_HOST = \
str(config("LND_GRPC_HOST", cast=str, default="localhost")) + \
":" + str(config("LND_GRPC_PORT", cast=str, default="10009"))
DISABLE_ONCHAIN = config("DISABLE_ONCHAIN", cast=bool, default=True)
MAX_SWAP_AMOUNT = config("MAX_SWAP_AMOUNT", cast=int, default=500_000)

View File

@ -35,7 +35,7 @@ class TestUtils(TestCase):
@patch("api.utils.config")
@patch("api.utils.requests.post")
def test_bitcoind_rpc(self, mock_post, mock_config):
mock_config.side_effect = ["url", "user", "password"]
mock_config.side_effect = ["host", "port", "user", "password"]
mock_post.return_value.json.return_value = {"result": "response"}
response = bitcoind_rpc("method", ["params"])
self.assertEqual(response, "response")

View File

@ -37,7 +37,9 @@ def bitcoind_rpc(method, params=None):
:return:
"""
BITCOIND_RPCURL = config("BITCOIND_RPCURL")
BITCOIND_RPCHOST = str(config("BITCOIND_RPCHOST", cast=str, default="127.0.0.1"))
BITCOIND_RPCPORT = str(config("BITCOIND_RPCPORT", cast=str, default="18332"))
BITCOIND_RPCURL = "http://" + BITCOIND_RPCHOST + ":" + BITCOIND_RPCPORT
BITCOIND_RPCUSER = config("BITCOIND_RPCUSER")
BITCOIND_RPCPASSWORD = config("BITCOIND_RPCPASSWORD")

View File

@ -115,7 +115,9 @@ services:
container_name: cele-worker-dev
restart: always
environment:
REDIS_URL: redis://localhost:6379
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_DB_NUMBER: 1
SKIP_COLLECT_STATIC: "true"
volumes:
- .:/usr/src/robosats
@ -132,7 +134,9 @@ services:
container_name: cele-beat-dev
restart: always
environment:
REDIS_URL: redis://localhost:6379
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_DB_NUMBER: 1
SKIP_COLLECT_STATIC: "true"
command: celery -A robosats beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
volumes:

View File

@ -149,7 +149,8 @@ services:
USE_TOR: False
MACAROON_PATH: 'data/chain/bitcoin/regtest/admin.macaroon'
CLN_DIR: '/cln/regtest/'
BITCOIND_RPCURL: 'http://127.0.0.1:18443'
BITCOIND_RPCHOST: '127.0.0.1'
BITCOIND_RPCPORT: '18443'
BITCOIND_RPCUSER: 'test'
BITCOIND_RPCPASSWORD: 'test'
env_file:
@ -190,7 +191,8 @@ services:
# USE_TOR: False
# MACAROON_PATH: 'data/chain/bitcoin/regtest/admin.macaroon'
# CLN_DIR: '/cln/regtest/'
# BITCOIND_RPCURL: 'http://127.0.0.1:18443'
# BITCOIND_RPCHOST: '127.0.0.1'
# BITCOIND_RPCPORT: '18443'
# BITCOIND_RPCUSER: 'test'
# BITCOIND_RPCPASSWORD: 'test'
# SKIP_COLLECT_STATIC: "true"
@ -210,4 +212,4 @@ volumes:
bitcoin:
lnd:
cln:
lndrobot:
lndrobot:

View File

@ -3,11 +3,15 @@ from __future__ import absolute_import, unicode_literals
import os
from datetime import timedelta
from decouple import config
from celery import Celery
from celery.schedules import crontab
# You can use rabbitmq instead here.
BASE_REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379")
BASE_REDIS_URL = \
"redis://" + str(config("REDIS_HOST", cast=str, default="localhost")) + \
":" + str(config("REDIS_PORT", cast=str, default="6379")) + \
"/" + str(config("REDIS_DB_NUMBER", cast=str, default="1"))
# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "robosats.settings")

View File

@ -231,7 +231,11 @@ CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [config("REDIS_URL")],
"hosts": [
"redis://" + str(config("REDIS_HOST", cast=str, default="localhost")) + \
":" + str(config("REDIS_PORT", cast=str, default="6379")) + \
"/" + str(config("REDIS_DB_NUMBER", cast=str, default="1"))
],
},
},
}
@ -239,7 +243,10 @@ CHANNEL_LAYERS = {
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": config("REDIS_URL"),
"LOCATION": \
"redis://" + str(config("REDIS_HOST", cast=str, default="localhost")) + \
":" + str(config("REDIS_PORT", cast=str, default="6379")) + \
"/" + str(config("REDIS_DB_NUMBER", cast=str, default="1")),
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"},
}
}