diff --git a/build_scripts/build_windows.ps1 b/build_scripts/build_windows.ps1 index 4807d9f81ea3..a027188b4f53 100644 --- a/build_scripts/build_windows.ps1 +++ b/build_scripts/build_windows.ps1 @@ -74,9 +74,9 @@ Write-Output " ---" npm run build Write-Output " ---" -Write-Output "Increase the stack for chiapos" +Write-Output "Increase the stack for chia command for (chia plots create) chiapos limitations" # editbin.exe needs to be in the path -editbin.exe /STACK:8000000 daemon\create_plots.exe +editbin.exe /STACK:8000000 daemon\chia.exe Write-Output " ---" $packageVersion = "$env:CHIA_INSTALLER_VERSION" diff --git a/build_scripts/daemon.spec b/build_scripts/daemon.spec index 36e63513c5a2..5c09015a9bd2 100644 --- a/build_scripts/daemon.spec +++ b/build_scripts/daemon.spec @@ -83,7 +83,7 @@ wallet = Analysis([f"{root}/src/server/start_wallet.py"], cipher=block_cipher, noarchive=False) -plotter = Analysis([f"{root}/src/cmds/chia.py"], +chia = Analysis([f"{root}/src/cmds/chia.py"], pathex=[f"{root}/venv/lib/python3.7/site-packages/aiter/", f"{root}"], binaries = [], datas=[version_data], @@ -122,33 +122,18 @@ harvester = Analysis([f"{root}/src/server/start_harvester.py"], cipher=block_cipher, noarchive=False) -check_plots = Analysis([f"{root}/src/cmds/chia.py"], - pathex=[f"{root}/venv/lib/python3.7/site-packages/aiter/", f"{root}"], - binaries = [], - datas=[version_data], - hiddenimports=subcommand_modules, - hookspath=[], - runtime_hooks=[], - excludes=[], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher, - noarchive=False) - daemon_pyz = PYZ(daemon.pure, daemon.zipped_data, cipher=block_cipher) full_node_pyz = PYZ(full_node.pure, full_node.zipped_data, cipher=block_cipher) wallet_pyz = PYZ(wallet.pure, wallet.zipped_data, cipher=block_cipher) -plotter_pyz = PYZ(plotter.pure, plotter.zipped_data, +chia_pyz = PYZ(chia.pure, chia.zipped_data, cipher=block_cipher) farmer_pyz = PYZ(farmer.pure, farmer.zipped_data, cipher=block_cipher) harvester_pyz = PYZ(harvester.pure, harvester.zipped_data, cipher=block_cipher) -check_plots_pyz = PYZ(check_plots.pure, check_plots.zipped_data, - cipher=block_cipher) daemon_exe = EXE(daemon_pyz, daemon.scripts, @@ -179,11 +164,11 @@ wallet_exe = EXE(wallet_pyz, bootloader_ignore_signals=False, strip=False) -plotter_exe = EXE(plotter_pyz, - plotter.scripts, +chia_exe = EXE(chia_pyz, + chia.scripts, [], exclude_binaries=True, - name='create_plots', + name='chia', debug=False, bootloader_ignore_signals=False, strip=False) @@ -206,15 +191,6 @@ harvester_exe = EXE(harvester_pyz, bootloader_ignore_signals=False, strip=False) -check_plots_exe = EXE(check_plots_pyz, - check_plots.scripts, - [], - exclude_binaries=True, - name='check_plots', - debug=False, - bootloader_ignore_signals=False, - strip=False) - coll = COLLECT(daemon_exe, daemon.binaries, daemon.zipfiles, @@ -230,10 +206,10 @@ coll = COLLECT(daemon_exe, wallet.zipfiles, wallet.datas, - plotter_exe, - plotter.binaries, - plotter.zipfiles, - plotter.datas, + chia_exe, + chia.binaries, + chia.zipfiles, + chia.datas, farmer_exe, farmer.binaries, @@ -245,10 +221,6 @@ coll = COLLECT(daemon_exe, harvester.zipfiles, harvester.datas, - check_plots_exe, - check_plots.binaries, - check_plots.zipfiles, - check_plots.datas, strip = False, upx_exclude = [], name = 'daemon' diff --git a/build_scripts/daemon_windows.spec b/build_scripts/daemon_windows.spec index 2963568aefec..51ff9e45cc6e 100644 --- a/build_scripts/daemon_windows.spec +++ b/build_scripts/daemon_windows.spec @@ -86,7 +86,7 @@ wallet = Analysis([f"../src/server/start_wallet.py"], cipher=block_cipher, noarchive=False) -plotter = Analysis([f"../src/cmds/chia.py"], +chia = Analysis([f"../src/cmds/chia.py"], pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f".."], binaries = [], datas=[version_data], @@ -125,33 +125,18 @@ harvester = Analysis([f"../src/server/start_harvester.py"], cipher=block_cipher, noarchive=False) -check_plots = Analysis([f"../src/cmds/chia.py"], - pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"], - binaries = [], - datas=[version_data], - hiddenimports=subcommand_modules, - hookspath=[], - runtime_hooks=[], - excludes=[], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher, - noarchive=False) - daemon_pyz = PYZ(daemon.pure, daemon.zipped_data, cipher=block_cipher) full_node_pyz = PYZ(full_node.pure, full_node.zipped_data, cipher=block_cipher) wallet_pyz = PYZ(wallet.pure, wallet.zipped_data, cipher=block_cipher) -plotter_pyz = PYZ(plotter.pure, plotter.zipped_data, +chia_pyz = PYZ(chia.pure, chia.zipped_data, cipher=block_cipher) farmer_pyz = PYZ(farmer.pure, farmer.zipped_data, cipher=block_cipher) harvester_pyz = PYZ(harvester.pure, harvester.zipped_data, cipher=block_cipher) -check_plots_pyz = PYZ(check_plots.pure, check_plots.zipped_data, - cipher=block_cipher) daemon_exe = EXE(daemon_pyz, daemon.scripts, @@ -182,11 +167,11 @@ wallet_exe = EXE(wallet_pyz, bootloader_ignore_signals=False, strip=False) -plotter_exe = EXE(plotter_pyz, - plotter.scripts, +chia_exe = EXE(chia_pyz, + chia.scripts, [], exclude_binaries=True, - name='create_plots', + name='chia', debug=False, bootloader_ignore_signals=False, strip=False) @@ -209,15 +194,6 @@ harvester_exe = EXE(harvester_pyz, bootloader_ignore_signals=False, strip=False) -check_plots_exe = EXE(check_plots_pyz, - check_plots.scripts, - [], - exclude_binaries=True, - name='check_plots', - debug=False, - bootloader_ignore_signals=False, - strip=False) - coll = COLLECT(daemon_exe, daemon.binaries, daemon.zipfiles, @@ -233,10 +209,10 @@ coll = COLLECT(daemon_exe, wallet.zipfiles, wallet.datas, - plotter_exe, - plotter.binaries, - plotter.zipfiles, - plotter.datas, + chia_exe, + chia.binaries, + chia.zipfiles, + chia.datas, farmer_exe, farmer.binaries, @@ -248,10 +224,6 @@ coll = COLLECT(daemon_exe, harvester.zipfiles, harvester.datas, - check_plots_exe, - check_plots.binaries, - check_plots.zipfiles, - check_plots.datas, strip = False, upx_exclude = [], name = 'daemon' diff --git a/setup.py b/setup.py index ebed1515ae4d..e20e83a255bb 100644 --- a/setup.py +++ b/setup.py @@ -87,6 +87,8 @@ kwargs = dict( "chia_timelord = src.server.start_timelord:main", "chia_timelord_launcher = src.timelord_launcher:main", "chia_full_node_simulator = src.simulator.start_simulator:main", + "chia-check-plots = src.cmds.chia:main plots check", + "chia-create-plots = src.cmds.chia:main plots check", ] }, package_data={ diff --git a/src/cmds/plots.py b/src/cmds/plots.py index 1c3ac7918e2b..a8ad814cc856 100644 --- a/src/cmds/plots.py +++ b/src/cmds/plots.py @@ -1,12 +1,9 @@ from pathlib import Path import logging -import pathlib from src.plotting.plot_tools import add_plot_directory from src.plotting.create_plots import create_plots from src.plotting.check_plots import check_plots from src.util.logging import initialize_logging -from argparse import ArgumentParser -from src.util.default_root import DEFAULT_ROOT_PATH log = logging.getLogger(__name__) @@ -111,22 +108,3 @@ def handler(args, parser): elif command == "add": str_path = args.final_dir add_plot_directory(str_path, root_path) - - -def main(): - # TODO: remove: this is a hack to get pypacker to be able to call the script - parser: ArgumentParser = ArgumentParser(description="Chia plots") - parser.add_argument( - "-r", - "--root-path", - help="Config file root (defaults to %s)." % DEFAULT_ROOT_PATH, - type=pathlib.Path, - default=DEFAULT_ROOT_PATH, - ) - make_parser(parser) - args = parser.parse_args() - handler(args, parser) - - -if __name__ == "__main__": - main() diff --git a/src/daemon/server.py b/src/daemon/server.py index 0005ffb98b37..7a946cd4cc19 100644 --- a/src/daemon/server.py +++ b/src/daemon/server.py @@ -235,7 +235,9 @@ class WebSocketServer: if error is None: try: self.log.info(f"Start potting: {command_args}") - process, pid_path = launch_plotter(self.root_path, command_args) + process, pid_path = launch_plotter( + self.root_path, service_name, command_args + ) self.services[service_name] = process success = True except (subprocess.SubprocessError, IOError): @@ -252,18 +254,17 @@ class WebSocketServer: async def start_service(self, request): service_command = request["service"] - service_name = service_command.split()[0] error = None success = False - if not validate_service(service_name): + if not validate_service(service_command): error = "unknown service" - if service_name in self.services: - service = self.services[service_name] + if service_command in self.services: + service = self.services[service_command] r = service is not None and service.poll() is None if r is False: - self.services.pop(service_name) + self.services.pop(service_command) error = None else: error = "already running" @@ -271,13 +272,13 @@ class WebSocketServer: if error is None: try: process, pid_path = launch_service(self.root_path, service_command) - self.services[service_name] = process + self.services[service_command] = process success = True except (subprocess.SubprocessError, IOError): - log.exception(f"problem starting {service_name}") + log.exception(f"problem starting {service_command}") error = "start failed" - response = {"success": success, "service": service_name, "error": error} + response = {"success": success, "service": service_command, "error": error} return response async def stop_service(self, request): @@ -357,11 +358,10 @@ def plotter_log_path(root_path): return root_path / "plotter" / "plotter_log.txt" -def launch_plotter(root_path, service_array): +def launch_plotter(root_path, service_name, service_array): # we need to pass on the possibly altered CHIA_ROOT os.environ["CHIA_ROOT"] = str(root_path) - service_name = service_array[0] - service_executable = executable_for_service(service_name) + service_executable = executable_for_service(service_array[0]) # Swap service name with name of executable service_array[0] = service_executable @@ -406,8 +406,7 @@ def launch_service(root_path, service_command): # Innsert proper e service_array = service_command.split() - service_name = service_array[0] - service_executable = executable_for_service(service_name) + service_executable = executable_for_service(service_array[0]) service_array[0] = service_executable startupinfo = None if os.name == "nt": diff --git a/src/util/service_groups.py b/src/util/service_groups.py index ce0174694abe..6830471b8bb2 100644 --- a/src/util/service_groups.py +++ b/src/util/service_groups.py @@ -7,7 +7,6 @@ SERVICES_FOR_GROUP = { "wallet-server": "chia-wallet chia_full_node".split(), "introducer": "chia_introducer".split(), "simulator": "chia_full_node_simulator".split(), - "plotter": "chia plots create".split(), }