def start_manager():
    if get_manager_processes():
        raise ManagerError('Manager is already running.')

    directory = pathlib.Path().resolve()
    stateless_manager_path = os.path.join(directory, 'stateless-manager.exe')
    if not os.path.exists(stateless_manager_path):
        raise FileNotFoundError('Failed to find stateless-manager.')
    manager_log_file_path = os.path.join(directory, 'manager.log')
    manager_log_file = open(manager_log_file_path, 'a')

    chia_location, log_directory, jobs, manager_check_interval, max_concurrent, progress_settings, \
        notification_settings, debug_level, view_settings = get_config_info()

    extra_args = []

    args = [stateless_manager_path] + extra_args
    start_process(args=args, log_file=manager_log_file)
    time.sleep(1)
    if not get_manager_processes():
        print('warning: chia plotter not found')

    send_notifications(
        title='Plot manager started',
        body=f'Plot Manager has started on {socket.gethostname()}...',
        settings=notification_settings,
    )
    print('Plot Manager has started...')
Exemplo n.º 2
0
def stop_manager():
    processes = get_manager_processes()
    if not processes:
        print("No manager processes were found.")
        return
    for process in processes:
        try:
            process.terminate()
        except psutil.NoSuchProcess:
            pass
    if get_manager_processes():
        raise TerminationException("Failed to stop manager processes.")
    print("Successfully stopped manager processes.")
Exemplo n.º 3
0
def start_manager():
    if get_manager_processes():
        raise ManagerError('Manager is already running.')

    directory = pathlib.Path().resolve()
    stateless_manager_path = os.path.join(directory, 'stateless-manager.py')
    if not os.path.exists(stateless_manager_path):
        raise FileNotFoundError('Failed to find stateless-manager.')
    debug_log_file_path = os.path.join(directory, 'debug.log')
    debug_log_file = open(debug_log_file_path, 'a')
    python_file_path = sys.executable

    chia_location, log_directory, config_jobs, manager_check_interval, max_concurrent, max_for_phase_1, \
        minimum_minutes_between_jobs, progress_settings, notification_settings, debug_level, view_settings, \
        instrumentation_settings = get_config_info()

    load_jobs(config_jobs)

    test_configuration(chia_location=chia_location,
                       notification_settings=notification_settings,
                       instrumentation_settings=instrumentation_settings)

    extra_args = []
    if is_windows():
        pythonw_file_path = '\\'.join(
            python_file_path.split('\\')[:-1] + ['pythonw.exe'])
    else:
        pythonw_file_path = '\\'.join(
            python_file_path.split('\\')[:-1] + ['python &'])
        extra_args.append('&')
    if os.path.exists(pythonw_file_path):
        python_file_path = pythonw_file_path

    args = [python_file_path, stateless_manager_path] + extra_args
    start_process(args=args, log_file=debug_log_file)
    time.sleep(3)
    if not get_manager_processes():
        raise ManagerError(
            'Failed to start Manager. Please look at debug.log for more details on the error. It is in the same folder as manager.py.'
        )

    send_notifications(
        title='Plot manager started',
        body=f'Plot Manager has started on {socket.gethostname()}...',
        settings=notification_settings,
    )
    print('Plot Manager has started...')
Exemplo n.º 4
0
def stop_manager():
    chia_location, log_directory, config_jobs, manager_check_interval, max_concurrent, max_for_phase_1, \
        minimum_minutes_between_jobs, progress_settings, notification_settings, debug_level, view_settings, \
        instrumentation_settings = get_config_info()
    processes = get_manager_processes()
    if not processes:
        print("No manager processes were found.")
        return
    for process in processes:
        try:
            process.terminate()
        except psutil.NoSuchProcess:
            pass
    if get_manager_processes():
        raise TerminationException("Failed to stop manager processes.")

    send_notifications(
        title='Plot manager stopped',
        body=f'Plot Manager has stopped on {socket.gethostname()}...',
        settings=notification_settings,
    )
    print("Successfully stopped manager processes.")
Exemplo n.º 5
0
def print_view(jobs, running_work, analysis, drives, next_log_check,
               view_settings, loop, backend):
    # Job Table
    job_data = get_job_data(jobs=jobs,
                            running_work=running_work,
                            view_settings=view_settings,
                            backend=backend)

    # Drive Table
    drive_data = ''
    if view_settings.get('include_drive_info'):
        drive_data = get_drive_data(drives, running_work, job_data)

    manager_processes = get_manager_processes()

    if os.name == 'nt':
        os.system('cls')
    else:
        os.system('clear')
    print(pretty_print_job_data(job_data))
    print(f'Manager Status: {"Running" if manager_processes else "Stopped"}')
    print()

    if view_settings.get('include_drive_info'):
        print(drive_data)
    if view_settings.get('include_cpu'):
        print(f'CPU Usage: {psutil.cpu_percent()}%')
    if view_settings.get('include_ram'):
        ram_usage = psutil.virtual_memory()
        print(
            f'RAM Usage: {pretty_print_bytes(ram_usage.used, "gb")}/{pretty_print_bytes(ram_usage.total, "gb", 2, "GiB")}'
            f'({ram_usage.percent}%)')
    print()
    if view_settings.get('include_plot_stats'):
        print(
            f'Plots Completed Yesterday: {analysis["summary"].get(datetime.now().date() - timedelta(days=1), 0)}'
        )
        print(
            f'Plots Completed Today: {analysis["summary"].get(datetime.now().date(), 0)}'
        )
        print()
    if loop:
        print(
            f"Next log check at {next_log_check.strftime('%Y-%m-%d %H:%M:%S')}"
        )
    print()