add node env variable writing for production mode

This commit is contained in:
checktheroads 2020-01-20 10:18:54 -07:00
parent 65ccce5aff
commit 4e53435de9

View file

@ -84,11 +84,11 @@ async def build_ui():
return output_out["data"] return output_out["data"]
async def write_env(vars): async def write_env(variables):
"""Write environment variables to temporary JSON file. """Write environment variables to temporary JSON file.
Arguments: Arguments:
vars {dict} -- Environment variables to write. variables {dict} -- Environment variables to write.
Raises: Raises:
RuntimeError: Raised on any errors. RuntimeError: Raised on any errors.
@ -97,8 +97,8 @@ async def write_env(vars):
import ujson as json import ujson as json
from pathlib import Path from pathlib import Path
env_file = Path("/tmp/hyperglass.env.json") env_file = Path("/tmp/hyperglass.env.json") # noqa: S108
env_vars = json.dumps(vars) env_vars = json.dumps(variables)
try: try:
async with AIOFile(env_file, "w+") as ef: async with AIOFile(env_file, "w+") as ef:
@ -107,4 +107,4 @@ async def write_env(vars):
except Exception as e: except Exception as e:
raise RuntimeError(str(e)) raise RuntimeError(str(e))
return True return f"Wrote {env_vars} to {str(env_file)}"