From 41214ae68c91b72bd1d37ab86890a9f59e0c31ed Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Mon, 12 Jul 2021 22:32:14 -0600 Subject: [PATCH 01/26] Start on worker launch config wizard. --- .github/workflows/develop.yaml | 2 +- .github/workflows/main.yaml | 2 +- .github/workflows/test.yaml | 2 +- CHANGELOG.md | 5 + VERSION | 2 +- api/models/chia.py | 1 + config/chiadog.sample.yaml | 2 +- scripts/setup_databases.sh | 7 + web/actions/plotman.py | 14 +- web/routes.py | 8 +- web/templates/plotting.html | 4 + web/templates/views/timezones_select.html | 630 ++++++++++++++++++++++ web/templates/worker_launch.html | 326 +++++++++++ web/templates/workers.html | 38 +- 14 files changed, 1031 insertions(+), 12 deletions(-) create mode 100644 web/templates/views/timezones_select.html create mode 100644 web/templates/worker_launch.html diff --git a/.github/workflows/develop.yaml b/.github/workflows/develop.yaml index 985c873e..47525d68 100644 --- a/.github/workflows/develop.yaml +++ b/.github/workflows/develop.yaml @@ -39,7 +39,7 @@ jobs: platforms: linux/amd64 push: true build-args: | - "CHIA_BRANCH=1.2.0" + "CHIA_BRANCH=1.2.1" "FLAX_BRANCH=main" tags: | ${{ secrets.DOCKERHUB_USERNAME }}/machinaris:develop diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7b8b3d17..004d9c0c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -40,7 +40,7 @@ jobs: platforms: linux/amd64 push: true build-args: | - "CHIA_BRANCH=1.2.0" + "CHIA_BRANCH=1.2.1" "FLAX_BRANCH=main" tags: | ${{ secrets.DOCKERHUB_USERNAME }}/machinaris:latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 03f0900b..ba494e33 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,7 +40,7 @@ jobs: platforms: linux/amd64 push: true build-args: | - "CHIA_BRANCH=1.2.0" + "CHIA_BRANCH=1.2.1" "FLAX_BRANCH=main" tags: | ${{ secrets.DOCKERHUB_USERNAME }}/machinaris:test diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c1f3cc1..d15ff176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.1] - 2021-07-? + +- Wizard on Workers page to create a Docker run/compose based on your settings. [Issue #97](https://github.com/guydavis/machinaris/issues/97) +- Update to patch release of Chia 1.2.1, including a fix for harvester cache updates. See their [changelog for details](https://github.com/Chia-Network/chia-blockchain/releases/tag/1.2.1). + ## [0.5.0] - 2021-07-09 - Support for [official Chia pools](https://github.com/guydavis/machinaris/issues/131). Chia and Madmax plotters can create portable plots. diff --git a/VERSION b/VERSION index 79a2734b..5d4294b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 \ No newline at end of file +0.5.1 \ No newline at end of file diff --git a/api/models/chia.py b/api/models/chia.py index 1155a5f6..e41bbd80 100644 --- a/api/models/chia.py +++ b/api/models/chia.py @@ -15,6 +15,7 @@ class FarmSummary: def __init__(self, cli_stdout=None, farm_plots=None): if cli_stdout: next_line_local_harvester = False + self.plot_count = 0 self.plots_size = None for line in cli_stdout: if next_line_local_harvester: diff --git a/config/chiadog.sample.yaml b/config/chiadog.sample.yaml index 5558c78c..a0211a19 100644 --- a/config/chiadog.sample.yaml +++ b/config/chiadog.sample.yaml @@ -21,7 +21,7 @@ chia_logs: # on your farm performance at the specified time of the day. daily_stats: enable: true - time_of_day: 21 + time_of_day: 20 # We support a lot of notifiers, please check the README for more # information. You can delete the sections which you aren't using. diff --git a/scripts/setup_databases.sh b/scripts/setup_databases.sh index 55b2627e..d05f67c9 100644 --- a/scripts/setup_databases.sh +++ b/scripts/setup_databases.sh @@ -7,6 +7,13 @@ mkdir -p /root/.chia/machinaris/logs mkdir -p /root/.chia/machinaris/dbs mkdir -p /root/.chia/chiadog/dbs +# Optional reset parameter will remove broken DBs, allowing fresh setup of status +if [ $1 == 'reset' ]; then + mv /root/.chia/machinaris/dbs/machinaris.db /root/.chia/machinaris/dbs/machinaris.db.bak + mv /root/.chia/machinaris/dbs/stats.db /root/.chia/machinaris/dbs/stats.db.bak + mv /root/.chia/chiadog/dbs/chiadog.db /root/.chia/chiadog/dbs/chiadog.db.bak +fi + # If old databases not managed by flask-migrate yet if [ ! -f /root/.chia/machinaris/dbs/.managed ] && [ -f /root/.chia/machinaris/dbs/stats.db ]; then cd /root/.chia/machinaris/dbs diff --git a/web/actions/plotman.py b/web/actions/plotman.py index f07aa517..d1780127 100644 --- a/web/actions/plotman.py +++ b/web/actions/plotman.py @@ -199,4 +199,16 @@ def analyze(plot_file, plotters): app.logger.info("Plotter on {0} returned an unexpected error: {1}".format(plotter.hostname, response.status_code)) except: app.logger.info(traceback.format_exc()) - return make_response("Sorry, not plotting job log found. Perhaps plot was made elsewhere?", 200) \ No newline at end of file + return make_response("Sorry, not plotting job log found. Perhaps plot was made elsewhere?", 200) + +def load_plotting_keys(): + farmer_pk = load_key_pk('Farmer') + pool_pk = load_key_pk('Pool') + pool_contract_address = load_pool_contract_address() + if not farmer_pk: + farmer_pk = None if os.environ['farmer_pk'] == 'null' else os.environ['farmer_pk'] + if not pool_pk: + pool_pk = None if os.environ['pool_pk'] == 'null' else os.environ['pool_pk'] + if not pool_contract_address: + pool_contract_address = None if os.environ['pool_contract_address'] == 'null' else os.environ['pool_contract_address'] + return [farmer_pk, pool_pk, pool_contract_address] diff --git a/web/routes.py b/web/routes.py index d4fd954b..9a7ef446 100644 --- a/web/routes.py +++ b/web/routes.py @@ -266,7 +266,13 @@ def logfile(): else: abort(500, "Unsupported log type: {0}".format(log_type)) +@app.route('/worker_launch') +def worker_launch(): + [farmer_pk, pool_pk, pool_contract_address] = plotman.load_plotting_keys() + return render_template('worker_launch.html', farmer_pk=farmer_pk, + pool_pk=pool_pk, pool_contract_address=pool_contract_address) + @app.route('/favicon.ico') def favicon(): return send_from_directory(os.path.join(app.root_path, 'static'), - 'favicon.ico', mimetype='image/vnd.microsoft.icon') \ No newline at end of file + 'favicon.ico', mimetype='image/vnd.microsoft.icon') diff --git a/web/templates/plotting.html b/web/templates/plotting.html index 7857cbf2..48e31616 100644 --- a/web/templates/plotting.html +++ b/web/templates/plotting.html @@ -30,7 +30,11 @@
Plotting Status: {{ plotting.display_status }} {% if plotting.display_status == 'Active' %} + {% if plotting.rows|length == 1 %} + - {{ plotting.rows|length }} job. + {% else %} - {{ plotting.rows|length }} jobs. + {% endif %} {% endif %}
diff --git a/web/templates/views/timezones_select.html b/web/templates/views/timezones_select.html new file mode 100644 index 00000000..3d49ebec --- /dev/null +++ b/web/templates/views/timezones_select.html @@ -0,0 +1,630 @@ + \ No newline at end of file diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html new file mode 100644 index 00000000..ad7a8897 --- /dev/null +++ b/web/templates/worker_launch.html @@ -0,0 +1,326 @@ + + + + + + + + + + + Worker Launch + + + + + +
+
+

Machinaris Worker - Launch Config

+

+
+
+ + +
+
+ + +
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+ + {% include 'views/timezones_select.html' %} +
+
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+
+
+

Volume Mounts

+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + + +

Docker Run

+

+    
+
+ + + +

Docker Compose

+
+TODO
+        
+
+ + + + \ No newline at end of file diff --git a/web/templates/workers.html b/web/templates/workers.html index fdf4bec9..2b845d2d 100644 --- a/web/templates/workers.html +++ b/web/templates/workers.html @@ -2,10 +2,29 @@ {% block content %} +
+
+ + + +
+
+
Machinaris - Workers
+ +
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} @@ -51,8 +70,16 @@
- +
+
+ +
+
+ +
+
@@ -74,10 +101,11 @@
No Machinaris workers have reported status successfully.
Please check each expected worker's log files.
-
For more, see the Machinaris wiki.
+
For more, see the Machinaris wiki.
-
-
+
+
{% endif %} From 65abb38c48a92dfed749d168c6c3c3e35ed83620 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Tue, 13 Jul 2021 19:35:28 -0600 Subject: [PATCH 02/26] More work on Worker Launch wizard. --- web/templates/worker_launch.html | 271 ++++++++++++++++++++++++------- 1 file changed, 213 insertions(+), 58 deletions(-) diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index ad7a8897..d2c59caa 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -46,20 +46,21 @@ @@ -119,34 +203,27 @@

Machinaris Worker - Launch Config

-
-
- - -
-
- - -
-
- +
- +
- + @@ -174,40 +251,51 @@

Machinaris Worker - Launch Config

-
+
- +
-
- - +
+ + +
+
+ +
- +
- +
+ value="{{pool_contract_address}}" id="pool_contract_address" onkeyup="updateDocker()">
- +
- + @@ -218,7 +306,8 @@

Machinaris Worker - Launch Config

- +
@@ -237,56 +326,62 @@

Machinaris Worker - Launch Config

- +
-
+
+ +
+

Volume Mounts

-

Volume Mounts

- - + +
- - + +
- - - +
- - + +
- - + +
- - - +
@@ -303,14 +398,14 @@

Volume Mounts

- +

Docker Run


     
- +

Docker Compose

@@ -321,6 +416,66 @@

Docker Compose

+ \ No newline at end of file From 013cc68bea53012b745cbb625d16d33e042d158c Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Tue, 13 Jul 2021 20:02:00 -0600 Subject: [PATCH 03/26] Guard against duplicate plots on same system. --- api/schedules/status_plots.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/api/schedules/status_plots.py b/api/schedules/status_plots.py index 23b4d309..5f93ed97 100644 --- a/api/schedules/status_plots.py +++ b/api/schedules/status_plots.py @@ -21,16 +21,24 @@ def update(): try: hostname = utils.get_hostname() plots_farming = chia_cli.load_plots_farming() + plots_by_id = {} payload = [] for plot in plots_farming.rows: - payload.append({ - "plot_id": plot['plot_id'], - "hostname": hostname, - "dir": plot['dir'], - "file": plot['file'], - "created_at": plot['created_at'], - "size": plot['size'], - }) + plot_id = plot['plot_id'] + if plot_id in plots_by_id: + other_plot = plots_by_id[plot_id] + app.logger.info("Skipping addition of plot at {0}/{1} because same plot_id found at {2}/{3}".format( + plot['dir'], plot['file'], other_plot['dir'], other_plot['file'])) + else: # No conflict so add it to plots list + plots_by_id[plot_id] = plot + payload.append({ + "plot_id": plot_id, + "hostname": hostname, + "dir": plot['dir'], + "file": plot['file'], + "created_at": plot['created_at'], + "size": plot['size'], + }) if len(payload) > 0: utils.send_post('/plots/', payload, debug=False) else: From 7b9cd899eb4a45bb5158b0128ef0d6037e1c8ddd Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Wed, 14 Jul 2021 20:55:40 -0600 Subject: [PATCH 04/26] Plots now unique. Docker Compose. Chia 1.2.2 --- .github/workflows/develop.yaml | 2 +- .github/workflows/main.yaml | 2 +- .github/workflows/test.yaml | 2 +- CHANGELOG.md | 2 +- api/migrations/versions/bdfe8db75307_.py | 85 ++++++++++++++ common/models/plots.py | 6 +- config/plotman.sample.yaml | 25 ++-- scripts/setup_databases.sh | 2 +- web/models/chia.py | 21 ++-- web/templates/worker_launch.html | 138 ++++++++++++++++++++--- 10 files changed, 242 insertions(+), 43 deletions(-) create mode 100644 api/migrations/versions/bdfe8db75307_.py diff --git a/.github/workflows/develop.yaml b/.github/workflows/develop.yaml index 47525d68..1a729a5c 100644 --- a/.github/workflows/develop.yaml +++ b/.github/workflows/develop.yaml @@ -39,7 +39,7 @@ jobs: platforms: linux/amd64 push: true build-args: | - "CHIA_BRANCH=1.2.1" + "CHIA_BRANCH=1.2.2" "FLAX_BRANCH=main" tags: | ${{ secrets.DOCKERHUB_USERNAME }}/machinaris:develop diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 004d9c0c..5bf38741 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -40,7 +40,7 @@ jobs: platforms: linux/amd64 push: true build-args: | - "CHIA_BRANCH=1.2.1" + "CHIA_BRANCH=1.2.2" "FLAX_BRANCH=main" tags: | ${{ secrets.DOCKERHUB_USERNAME }}/machinaris:latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ba494e33..537e8a00 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,7 +40,7 @@ jobs: platforms: linux/amd64 push: true build-args: | - "CHIA_BRANCH=1.2.1" + "CHIA_BRANCH=1.2.2" "FLAX_BRANCH=main" tags: | ${{ secrets.DOCKERHUB_USERNAME }}/machinaris:test diff --git a/CHANGELOG.md b/CHANGELOG.md index d15ff176..497fbbcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format ## [0.5.1] - 2021-07-? - Wizard on Workers page to create a Docker run/compose based on your settings. [Issue #97](https://github.com/guydavis/machinaris/issues/97) -- Update to patch release of Chia 1.2.1, including a fix for harvester cache updates. See their [changelog for details](https://github.com/Chia-Network/chia-blockchain/releases/tag/1.2.1). +- Update to patch release of Chia 1.2.2, including a fix for harvester cache updates. See their [changelog for details](https://github.com/Chia-Network/chia-blockchain/releases/tag/1.2.2). ## [0.5.0] - 2021-07-09 diff --git a/api/migrations/versions/bdfe8db75307_.py b/api/migrations/versions/bdfe8db75307_.py new file mode 100644 index 00000000..d5d87701 --- /dev/null +++ b/api/migrations/versions/bdfe8db75307_.py @@ -0,0 +1,85 @@ +"""empty message + +Revision ID: bdfe8db75307 +Revises: 51f75e96b994 +Create Date: 2021-07-14 16:11:24.451771 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.sql import func + + +# revision identifiers, used by Alembic. +revision = 'bdfe8db75307' +down_revision = '51f75e96b994' +branch_labels = None +depends_on = None + + +def upgrade(engine_name): + globals()["upgrade_%s" % engine_name]() + + +def downgrade(engine_name): + globals()["downgrade_%s" % engine_name]() + + + + + +def upgrade_(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('plots') + op.create_table('plots', + sa.Column('hostname', sa.String(length=255), primary_key=True), + sa.Column('plot_id', sa.String(length=16), primary_key=True), + sa.Column('dir', sa.String(length=255), nullable=False), + sa.Column('file', sa.String(length=255), nullable=False), + sa.Column('size', sa.Integer, nullable=False), + sa.Column('created_at', sa.String(length=64), nullable=False), + sa.Column('updated_at', sa.DateTime(), onupdate=func.now()), + sa.PrimaryKeyConstraint('hostname', 'plot_id') + ) + # ### end Alembic commands ### + + +def downgrade_(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('plots') + op.create_table('plots', + sa.Column('plot_id', sa.String(length=16), primary_key=True), + sa.Column('hostname', sa.String(length=255), nullable=False), + sa.Column('dir', sa.String(length=255), nullable=False), + sa.Column('file', sa.String(length=255), nullable=False), + sa.Column('size', sa.Integer, nullable=False), + sa.Column('created_at', sa.String(length=64), nullable=False), + sa.Column('updated_at', sa.DateTime(), onupdate=func.now()), + sa.PrimaryKeyConstraint('plot_id') + ) + # ### end Alembic commands ### + + +def upgrade_stats(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade_stats(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def upgrade_chiadog(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade_chiadog(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + diff --git a/common/models/plots.py b/common/models/plots.py index 93ae4309..d1ddb8aa 100644 --- a/common/models/plots.py +++ b/common/models/plots.py @@ -9,12 +9,10 @@ class Plot(db.Model): __tablename__ = "plots" - plot_id = sa.Column(sa.String(length=8), primary_key=True) - hostname = sa.Column(sa.String(length=255), nullable=False) + hostname = sa.Column(sa.String(length=255), primary_key=True) + plot_id = sa.Column(sa.String(length=16), primary_key=True) dir = sa.Column(sa.String(length=255), nullable=False) file = sa.Column(sa.String(length=255), nullable=False) size = sa.Column(sa.Integer, nullable=False) created_at = sa.Column(sa.String(length=64), nullable=False) updated_at = sa.Column(sa.DateTime(), onupdate=func.now()) - - \ No newline at end of file diff --git a/config/plotman.sample.yaml b/config/plotman.sample.yaml index a50dac7f..8d34700b 100644 --- a/config/plotman.sample.yaml +++ b/config/plotman.sample.yaml @@ -28,19 +28,6 @@ directories: tmp: - /plotting - # Optional: Allows overriding some characteristics of certain tmp - # directories. This contains a map of tmp directory names to - # attributes. If a tmp directory and attribute is not listed here, - # it uses the default attribute setting from the main configuration. - # - # Currently support override parameters: - # - tmpdir_max_jobs - #tmp_overrides: - # In this example, /plotting3 is larger than the other tmp - # dirs and it can hold more plots than the default. - #/plotting3: - # tmpdir_max_jobs: 5 - # Optional: tmp2 directory. If specified, will be passed to # the chia and madmax plotters as the '-2' param. # tmp2: /plotting2 @@ -90,6 +77,18 @@ scheduling: # How often the daemon wakes to consider starting a new plot job, in seconds. polling_time_s: 20 + # Optional: Allows overriding some characteristics of certain tmp + # directories. This contains a map of tmp directory names to + # attributes. If a tmp directory and attribute is not listed here, + # it uses the default attribute setting from the main configuration. + # + # Currently support override parameters: + # - tmpdir_max_jobs + #tmp_overrides: + # In this example, /plotting3 is larger than the other tmp + # dirs and it can hold more plots than the default. + #/plotting3: + # tmpdir_max_jobs: 5 # Configure the plotter. See: https://github.com/guydavis/machinaris/wiki/Plotman#plotting plotting: diff --git a/scripts/setup_databases.sh b/scripts/setup_databases.sh index d05f67c9..86c8c5c2 100644 --- a/scripts/setup_databases.sh +++ b/scripts/setup_databases.sh @@ -8,7 +8,7 @@ mkdir -p /root/.chia/machinaris/dbs mkdir -p /root/.chia/chiadog/dbs # Optional reset parameter will remove broken DBs, allowing fresh setup of status -if [ $1 == 'reset' ]; then +if [[ $1 == "reset" ]]; then mv /root/.chia/machinaris/dbs/machinaris.db /root/.chia/machinaris/dbs/machinaris.db.bak mv /root/.chia/machinaris/dbs/stats.db /root/.chia/machinaris/dbs/stats.db.bak mv /root/.chia/chiadog/dbs/chiadog.db /root/.chia/chiadog/dbs/chiadog.db.bak diff --git a/web/models/chia.py b/web/models/chia.py index 6a34b47b..5c15f60b 100644 --- a/web/models/chia.py +++ b/web/models/chia.py @@ -66,14 +66,21 @@ class FarmPlots: def __init__(self, plots): self.columns = ['worker', 'plot_id', 'dir', 'plot', 'create_date', 'size'] self.rows = [] + plots_by_id = {} for plot in plots: - self.rows.append({ \ - 'worker': plot.hostname, \ - 'plot_id': plot.plot_id, \ - 'dir': plot.dir, \ - 'plot': plot.file, \ - 'create_date': plot.created_at, \ - 'size': plot.size }) + if plot.plot_id in plots_by_id: + other_plot = plots_by_id[plot.plot_id] + app.logger.info("Skipping listing of plot on {0} at {1}/{2} because same plot_id found on {3} at {4}/{5}".format( + plot.hostname, plot.dir, plot.file, other_plot.hostname, other_plot.dir, other_plot.file)) + else: # No conflict so add it to plots list + plots_by_id[plot.plot_id] = plot + self.rows.append({ \ + 'worker': plot.hostname, \ + 'plot_id': plot.plot_id, \ + 'dir': plot.dir, \ + 'plot': plot.file, \ + 'create_date': plot.created_at, \ + 'size': plot.size }) class BlockchainChallenges: diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index d2c59caa..0a4209a1 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -100,20 +100,24 @@ function updateAppData() { var os = getRadioButtonValue('os') if (os == 'windows') { - $('#appdata').text = '%APPDATA%/.machinaris'; - document.getElementById('volume_host_path0').value = "C:/chia_plots"; - document.getElementById('volume_host_path1').value = "C:/chia_plotting"; + document.getElementById('appdata').value = '%APPDATA%/.machinaris'; + document.getElementById('volume_host_path0').value = "C:/my_chia_plots"; + document.getElementById('volume_host_path1').value = "C:/my_chia_plotting"; } else if (os == 'macintosh') { - $('#appdata').text = '~/.machinaris'; + document.getElementById('appdata').value = '~/.machinaris'; document.getElementById('volume_host_path0').value = "/Volumes/disk1"; document.getElementById('volume_host_path1').value = "/Volumes/temp1"; } else { - $('#appdata').text = '~/.machinaris'; + document.getElementById('appdata').value = '~/.machinaris'; document.getElementById('volume_host_path0').value = "/mnt/disk1"; document.getElementById('volume_host_path1').value = "/mnt/temp1"; } } function updateDocker() { + updateDockerRun(); + updateDockerCompose(); + } + function updateDockerRun() { var os = getRadioButtonValue('os') if (os == 'windows') { line_end = ' `\n'; @@ -122,12 +126,25 @@ } cmd = 'docker run' + line_end; cmd += ' -d -t --name machinaris' + line_end; - if (os == 'windows') { - cmd += ' -h (hostname)' + line_end; - cmd += ' --dns (Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object -ExpandProperty ServerAddresses)' + line_end; - } else { - cmd += ' -h $(hostname -s)' + line_end; - cmd += " --dns $(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2)" + line_end; + if (document.getElementById("worker_hostname").value) { + cmd += ' -h ' + document.getElementById("worker_hostname").value + line_end; + } + else { + if (os == 'windows') { + cmd += ' -h (hostname)' + line_end; + } else { + cmd += ' -h $(hostname -s)' + line_end; + } + } + if (document.getElementById("dns_ip_addr").value) { + cmd += ' --dns ' + document.getElementById("dns_ip_addr").value + line_end; + } + else { + if (os == 'windows') { + cmd += ' --dns (Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object -ExpandProperty ServerAddresses)' + line_end; + } else { + cmd += " --dns $(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2)" + line_end; + } } cmd += ' -v "' + document.getElementById("appdata").value + ':/root/.chia"' + line_end; var cur_vols = $('#volumes').children().length @@ -189,6 +206,85 @@ cmd += ' ghcr.io/guydavis/machinaris'; $('#run').html(cmd); } + function updateDockerCompose() { + var line_end = ' \n'; + var os = getRadioButtonValue('os') + cmd = "version: '3.8'" + line_end; + cmd += "machinaris:" + line_end; + cmd += " image: ghcr.io/guydavis/machinaris" + line_end; + if (document.getElementById("worker_hostname").value) { + cmd += ' hostname:' + document.getElementById("worker_hostname").value + line_end; + } + if (document.getElementById("dns_ip_addr").value) { + cmd += ' dns:' + document.getElementById("dns_ip_addr").value + line_end; + } + cmd += ' restart: always' + line_end; + cmd += ' tty: true' + line_end; + cmd += ' volumes:' + line_end; + cmd += ' - "' + document.getElementById("appdata").value + ':/root/.chia"' + line_end; + var cur_vols = $('#volumes').children().length + var plots_dir = [] + $('#volumes').children().each( (index, element) => { + volume_host_path = document.getElementById("volume_host_path" + index).value; + volume_container_path = document.getElementById("volume_container_path" + index).value; + cmd += ' - "' + volume_host_path + ':' + volume_container_path + '"' + line_end; + if ($('#volume_type' + index).val() == 'plots') { + plots_dir.push(volume_container_path) + } + }); + cmd += ' environment:' + line_end; + cmd += ' - TZ="' + $('#timezone').val() + '"' + line_end; + var mode = "" + if (document.getElementById('mode-harvester').checked) { + mode = "harvester"; + cmd += ' - farmer_address=' + document.getElementById("farmer_address").value + line_end; + cmd += ' - farmer_port=' + document.getElementById("farmer_port").value + line_end; + if (document.getElementById("blockchain-flax").checked) { + cmd += ' - flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; + } + } else if (document.getElementById('mode-plotter').checked) { + if (mode) { + mode += ',plotter' + line_end; + } + else { + mode = 'plotter' + line_end; + } + cmd += ' - "farmer_pk=' + document.getElementById("farmer_pk").value + '"' + line_end; + cmd += ' - "pool_pk=' + document.getElementById("pool_pk").value + line_end; + cmd += ' - "pool_contract_address=' + document.getElementById("pool_contract_address").value + '"' + line_end; + } + if (mode) { // harvester, plotter, or harvester+plotter + cmd += ' - mode=' + mode + line_end; + cmd += ' - controller_host=' + location.hostname + line_end; + } else { // fullnode + cmd += ' - mode=fullnode' + line_end; + } + if (document.getElementById("ip_addr").value) { + cmd += ' - worker_address=' + document.getElementById("ip_addr").value + line_end; + } + cmd += ' - plots_dir=' + plots_dir.join(':') + line_end; + var blockchains = 'chia' + if (document.getElementById("blockchain-flax").checked) { + blockchains += ',flax' + } + cmd += ' - blockchains=' + blockchains + line_end; + var auto_plot = getRadioButtonValue('auto_plot'); + if (auto_plot == "true") { + cmd += ' - AUTO_PLOT=' + auto_plot + line_end; + } + cmd += ' ports:' + line_end; + cmd += ' - 8926:8926' + line_end; + cmd += ' - 8927:8927' + line_end; + if (!mode) { // Defaults to fullnode + cmd += ' - 8444:8444' + line_end; + cmd += ' - 8447:8447' + line_end; + if (document.getElementById("blockchain-flax").checked) { + cmd += ' - 6888:6888' + line_end; + cmd += ' - 6885:6885' + line_end; + } + } + $('#compose').html(cmd); + } $(document).ready(function () { $('#plotting_keys_row').hide() //$('#farmer_address_row').hide() @@ -314,6 +410,20 @@

Machinaris Worker - Launch Config

{% include 'views/timezones_select.html' %}
+
+
+
+ + +
+
+
+ + +
+
@@ -335,9 +445,9 @@

Machinaris Worker - Launch Config

- - + +

Volume Mounts

From 51e53fcc95b690120cff5fc8a3708c2fdc033a18 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Wed, 14 Jul 2021 22:16:58 -0600 Subject: [PATCH 05/26] Worker launch fixes. --- scripts/start_machinaris.sh | 2 +- web/templates/worker_launch.html | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/start_machinaris.sh b/scripts/start_machinaris.sh index d09e9ab1..8257b864 100644 --- a/scripts/start_machinaris.sh +++ b/scripts/start_machinaris.sh @@ -11,7 +11,7 @@ if [ ${farmer_pk} != 'null' ]; then sed -i "s/^.*farmer_pk:.*$/ farmer_pk: ${farmer_pk}/g" /root/.chia/plotman/plotman.yaml fi if [ ${pool_pk} != 'null' ]; then - sed -i "s/^.*pool_pk:.*$/ pool_pk: ${pool_pk}/g" /root/.chia/plotman/plotman.yaml + sed -i "s/^.*pool_pk:.*$/ #pool_pk: ${pool_pk}/g" /root/.chia/plotman/plotman.yaml fi if [ ${pool_contract_address} != 'null' ]; then sed -i "s/^.*pool_contract_address:.*$/ pool_contract_address: ${pool_contract_address}/g" /root/.chia/plotman/plotman.yaml diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index 0a4209a1..4a25d557 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -143,16 +143,16 @@ if (os == 'windows') { cmd += ' --dns (Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object -ExpandProperty ServerAddresses)' + line_end; } else { - cmd += " --dns $(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2)" + line_end; + //cmd += " --dns $(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2)" + line_end; } } - cmd += ' -v "' + document.getElementById("appdata").value + ':/root/.chia"' + line_end; + cmd += ' -v ' + document.getElementById("appdata").value + ':/root/.chia' + line_end; var cur_vols = $('#volumes').children().length var plots_dir = [] $('#volumes').children().each( (index, element) => { volume_host_path = document.getElementById("volume_host_path" + index).value; volume_container_path = document.getElementById("volume_container_path" + index).value; - cmd += ' -v "' + volume_host_path + ':' + volume_container_path + '"' + line_end; + cmd += ' -v ' + volume_host_path + ':' + volume_container_path + line_end; if ($('#volume_type' + index).val() == 'plots') { plots_dir.push(volume_container_path) } @@ -166,7 +166,8 @@ if (document.getElementById("blockchain-flax").checked) { cmd += ' -e flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; } - } else if (document.getElementById('mode-plotter').checked) { + } + if (document.getElementById('mode-plotter').checked) { if (mode) { mode += ',plotter'; } @@ -174,7 +175,7 @@ mode = 'plotter'; } cmd += ' -e "farmer_pk=' + document.getElementById("farmer_pk").value + '"' + line_end; - cmd += ' -e "pool_pk=' + document.getElementById("pool_pk").value + line_end; + cmd += ' -e "pool_pk=' + document.getElementById("pool_pk").value + '"' + line_end; cmd += ' -e "pool_contract_address=' + document.getElementById("pool_contract_address").value + '"' + line_end; } if (mode) { // harvester, plotter, or harvester+plotter @@ -221,13 +222,13 @@ cmd += ' restart: always' + line_end; cmd += ' tty: true' + line_end; cmd += ' volumes:' + line_end; - cmd += ' - "' + document.getElementById("appdata").value + ':/root/.chia"' + line_end; + cmd += ' - ' + document.getElementById("appdata").value + ':/root/.chia' + line_end; var cur_vols = $('#volumes').children().length var plots_dir = [] $('#volumes').children().each( (index, element) => { volume_host_path = document.getElementById("volume_host_path" + index).value; volume_container_path = document.getElementById("volume_container_path" + index).value; - cmd += ' - "' + volume_host_path + ':' + volume_container_path + '"' + line_end; + cmd += ' - ' + volume_host_path + ':' + volume_container_path + line_end; if ($('#volume_type' + index).val() == 'plots') { plots_dir.push(volume_container_path) } @@ -242,15 +243,16 @@ if (document.getElementById("blockchain-flax").checked) { cmd += ' - flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; } - } else if (document.getElementById('mode-plotter').checked) { + } + if (document.getElementById('mode-plotter').checked) { if (mode) { - mode += ',plotter' + line_end; + mode += ',plotter'; } else { - mode = 'plotter' + line_end; + mode = 'plotter'; } cmd += ' - "farmer_pk=' + document.getElementById("farmer_pk").value + '"' + line_end; - cmd += ' - "pool_pk=' + document.getElementById("pool_pk").value + line_end; + cmd += ' - "pool_pk=' + document.getElementById("pool_pk").value + '"' + line_end; cmd += ' - "pool_contract_address=' + document.getElementById("pool_contract_address").value + '"' + line_end; } if (mode) { // harvester, plotter, or harvester+plotter From 3605e733ce8c3da88b320ba2a81f2af14244def5 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Thu, 15 Jul 2021 14:14:22 -0600 Subject: [PATCH 06/26] More fixes for wizard. --- dockerfile | 11 +++- web/models/chia.py | 4 +- web/templates/worker_launch.html | 101 +++++++++++++++++-------------- web/templates/workers.html | 4 +- 4 files changed, 70 insertions(+), 50 deletions(-) diff --git a/dockerfile b/dockerfile index a319a4e9..b0ea979b 100644 --- a/dockerfile +++ b/dockerfile @@ -110,10 +110,17 @@ ENV AUTO_PLOT=false VOLUME [ "/id_rsa" ] -# ports -EXPOSE 8555 +# Chia protocol port - forward at router EXPOSE 8444 +# Chia RPC port - DO NOT forward at router +EXPOSE 8447 +# Flax protocol port - forward at router +EXPOSE 6888 +# Flax RPC port - DO NOT forward at router +EXPOSE 6885 +# Machinaris WebUI - DO NOT forward at router, proxy if needed EXPOSE 8926 +# Machinaris API - DO NOT forward at router EXPOSE 8927 WORKDIR /chia-blockchain diff --git a/web/models/chia.py b/web/models/chia.py index 5c15f60b..16cdb304 100644 --- a/web/models/chia.py +++ b/web/models/chia.py @@ -30,11 +30,11 @@ def __init__(self, farms): if farm.mode == "fullnode": self.status = farm.status fullnode_plots_size = farm.plots_size - self.total_chia = '0.0' if not farm.total_chia else round(farm.total_chia, 3) + self.total_chia = '0.0' if not farm.total_chia else round(farm.total_chia, 6) self.netspace_display_size = '?' if not farm.netspace_size else converters.gib_to_fmt(farm.netspace_size) self.netspace_size = farm.netspace_size self.expected_time_to_win = farm.expected_time_to_win - self.total_flax = '0.0' if not farm.total_flax else round(farm.total_flax, 3) + self.total_flax = '0.0' if not farm.total_flax else round(farm.total_flax, 6) self.flax_netspace_display_size = '?' if not farm.flax_netspace_size else converters.gib_to_fmt(farm.flax_netspace_size) self.flax_netspace_size = farm.flax_netspace_size self.flax_expected_time_to_win = farm.flax_expected_time_to_win diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index 4a25d557..5db5047d 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -157,7 +157,7 @@ plots_dir.push(volume_container_path) } }); - cmd += ' -e TZ="' + $('#timezone').val() + '"' + line_end; + cmd += ' -e TZ=' + $('#timezone').val() + line_end; var mode = "" if (document.getElementById('mode-harvester').checked) { mode = "harvester"; @@ -174,13 +174,14 @@ else { mode = 'plotter'; } - cmd += ' -e "farmer_pk=' + document.getElementById("farmer_pk").value + '"' + line_end; - cmd += ' -e "pool_pk=' + document.getElementById("pool_pk").value + '"' + line_end; - cmd += ' -e "pool_contract_address=' + document.getElementById("pool_contract_address").value + '"' + line_end; + cmd += ' -e farmer_pk=' + document.getElementById("farmer_pk").value + line_end; + cmd += ' -e pool_pk=' + document.getElementById("pool_pk").value + line_end; + cmd += ' -e pool_contract_address=' + document.getElementById("pool_contract_address").value + line_end; } if (mode) { // harvester, plotter, or harvester+plotter cmd += ' -e mode=' + mode + line_end; - cmd += ' -e controller_host=' + location.hostname + line_end; + cmd += ' -e controller_host=' + document.getElementById("controller_host").value + line_end; + cmd += ' -e controller_api_port=' + document.getElementById("controller_api_port").value + line_end; } else { // fullnode cmd += ' -e mode=fullnode' + line_end; } @@ -210,38 +211,40 @@ function updateDockerCompose() { var line_end = ' \n'; var os = getRadioButtonValue('os') - cmd = "version: '3.8'" + line_end; - cmd += "machinaris:" + line_end; - cmd += " image: ghcr.io/guydavis/machinaris" + line_end; + cmd = "version: '3.9'" + line_end; + cmd += "services:" + line_end; + cmd += " machinaris:" + line_end; + cmd += " image: ghcr.io/guydavis/machinaris" + line_end; + cmd += " container_name: machinaris" + line_end; if (document.getElementById("worker_hostname").value) { - cmd += ' hostname:' + document.getElementById("worker_hostname").value + line_end; + cmd += ' hostname:' + document.getElementById("worker_hostname").value + line_end; } if (document.getElementById("dns_ip_addr").value) { - cmd += ' dns:' + document.getElementById("dns_ip_addr").value + line_end; + cmd += ' dns:' + document.getElementById("dns_ip_addr").value + line_end; } - cmd += ' restart: always' + line_end; - cmd += ' tty: true' + line_end; - cmd += ' volumes:' + line_end; - cmd += ' - ' + document.getElementById("appdata").value + ':/root/.chia' + line_end; + cmd += ' restart: always' + line_end; + cmd += ' tty: true' + line_end; + cmd += ' volumes:' + line_end; + cmd += ' - ' + document.getElementById("appdata").value + ':/root/.chia' + line_end; var cur_vols = $('#volumes').children().length var plots_dir = [] $('#volumes').children().each( (index, element) => { volume_host_path = document.getElementById("volume_host_path" + index).value; volume_container_path = document.getElementById("volume_container_path" + index).value; - cmd += ' - ' + volume_host_path + ':' + volume_container_path + line_end; + cmd += ' - ' + volume_host_path + ':' + volume_container_path + line_end; if ($('#volume_type' + index).val() == 'plots') { plots_dir.push(volume_container_path) } }); - cmd += ' environment:' + line_end; - cmd += ' - TZ="' + $('#timezone').val() + '"' + line_end; + cmd += ' environment:' + line_end; + cmd += ' - TZ=' + $('#timezone').val() + line_end; var mode = "" if (document.getElementById('mode-harvester').checked) { mode = "harvester"; - cmd += ' - farmer_address=' + document.getElementById("farmer_address").value + line_end; - cmd += ' - farmer_port=' + document.getElementById("farmer_port").value + line_end; + cmd += ' - farmer_address=' + document.getElementById("farmer_address").value + line_end; + cmd += ' - farmer_port=' + document.getElementById("farmer_port").value + line_end; if (document.getElementById("blockchain-flax").checked) { - cmd += ' - flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; + cmd += ' - flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; } } if (document.getElementById('mode-plotter').checked) { @@ -251,38 +254,39 @@ else { mode = 'plotter'; } - cmd += ' - "farmer_pk=' + document.getElementById("farmer_pk").value + '"' + line_end; - cmd += ' - "pool_pk=' + document.getElementById("pool_pk").value + '"' + line_end; - cmd += ' - "pool_contract_address=' + document.getElementById("pool_contract_address").value + '"' + line_end; + cmd += ' - farmer_pk=' + document.getElementById("farmer_pk").value + line_end; + cmd += ' - pool_pk=' + document.getElementById("pool_pk").value + line_end; + cmd += ' - pool_contract_address=' + document.getElementById("pool_contract_address").value + line_end; } if (mode) { // harvester, plotter, or harvester+plotter - cmd += ' - mode=' + mode + line_end; - cmd += ' - controller_host=' + location.hostname + line_end; + cmd += ' - mode=' + mode + line_end; + cmd += ' - controller_host=' + document.getElementById("controller_host").value + line_end; + cmd += ' - controller_api_port=' + document.getElementById("controller_api_port").value + line_end; } else { // fullnode - cmd += ' - mode=fullnode' + line_end; + cmd += ' - mode=fullnode' + line_end; } if (document.getElementById("ip_addr").value) { - cmd += ' - worker_address=' + document.getElementById("ip_addr").value + line_end; + cmd += ' - worker_address=' + document.getElementById("ip_addr").value + line_end; } - cmd += ' - plots_dir=' + plots_dir.join(':') + line_end; + cmd += ' - plots_dir=' + plots_dir.join(':') + line_end; var blockchains = 'chia' if (document.getElementById("blockchain-flax").checked) { blockchains += ',flax' } - cmd += ' - blockchains=' + blockchains + line_end; + cmd += ' - blockchains=' + blockchains + line_end; var auto_plot = getRadioButtonValue('auto_plot'); if (auto_plot == "true") { - cmd += ' - AUTO_PLOT=' + auto_plot + line_end; + cmd += ' - AUTO_PLOT=' + auto_plot + line_end; } - cmd += ' ports:' + line_end; - cmd += ' - 8926:8926' + line_end; - cmd += ' - 8927:8927' + line_end; + cmd += ' ports:' + line_end; + cmd += ' - 8926' + line_end; + cmd += ' - 8927' + line_end; if (!mode) { // Defaults to fullnode - cmd += ' - 8444:8444' + line_end; - cmd += ' - 8447:8447' + line_end; + cmd += ' - 8444' + line_end; + cmd += ' - 8447' + line_end; if (document.getElementById("blockchain-flax").checked) { - cmd += ' - 6888:6888' + line_end; - cmd += ' - 6885:6885' + line_end; + cmd += ' - 6888' + line_end; + cmd += ' - 6885' + line_end; } } $('#compose').html(cmd); @@ -291,6 +295,7 @@ $('#plotting_keys_row').hide() //$('#farmer_address_row').hide() $('#farmer_address').val(location.hostname) + $('#controller_host').val(location.hostname) updateDocker(); }); @@ -350,7 +355,7 @@

Machinaris Worker - Launch Config

- +
@@ -403,7 +408,7 @@

Machinaris Worker - Launch Config

- +
@@ -414,11 +419,21 @@

Machinaris Worker - Launch Config

-
+ + +
+
+ + +
+
+
+
-
@@ -521,9 +536,7 @@

Docker Run

Docker Compose

-
-TODO
-        
+

     
diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index 5db5047d..f25c406e 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -100,7 +100,7 @@ function updateAppData() { var os = getRadioButtonValue('os') if (os == 'windows') { - document.getElementById('appdata').value = '%APPDATA%/.machinaris'; + document.getElementById('appdata').value = '${APPDATA}/.machinaris'; document.getElementById('volume_host_path0').value = "C:/my_chia_plots"; document.getElementById('volume_host_path1').value = "C:/my_chia_plotting"; } else if (os == 'macintosh') { From 61a6f95b5609fedc1e3de86c01fa1400a825a476 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Thu, 15 Jul 2021 16:18:35 -0600 Subject: [PATCH 08/26] New kill switch. --- api/commands/plotman_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/commands/plotman_cli.py b/api/commands/plotman_cli.py index 7c3b8dae..7eb5da6c 100644 --- a/api/commands/plotman_cli.py +++ b/api/commands/plotman_cli.py @@ -76,13 +76,13 @@ def action_plots(job): #app.logger.info("About to {0} plots: {1}".format(action, plot_ids)) for plot_id in plot_ids: try: - prefix = "" + suffix = "" if action == "kill": - prefix = "printf 'y\n' |" + suffix = "--force" logfile = "/root/.chia/plotman/logs/plotman.log" log_fd = os.open(logfile, os.O_RDWR | os.O_CREAT) log_fo = os.fdopen(log_fd, "a+") - proc = Popen("{0} {1} {2} {3}".format(prefix, PLOTMAN_SCRIPT, action, plot_id), + proc = Popen("{0} {1} {2} {3}".format(PLOTMAN_SCRIPT, action, suffix, plot_id), shell=True, universal_newlines=True, stdout=log_fo, stderr=log_fo) except: app.logger.info('Failed to {0} selected plot {1}.'.format(action, plot_id)) From 90d055e3786e8dfd074fd8dec70ebf03799932f1 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Thu, 15 Jul 2021 16:32:34 -0600 Subject: [PATCH 09/26] Hide controller row when mode=fullnode. --- web/templates/worker_launch.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index f25c406e..99641655 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -81,6 +81,7 @@ } else { $('#plotting_keys_row').hide() } + toggleControllerAddressVisibility(); } function toggleFarmerAddressVisibility() { if (document.getElementById('mode-harvester').checked) { @@ -88,6 +89,14 @@ } else { $('#farmer_address_row').hide() } + toggleControllerAddressVisibility(); + } + function toggleControllerAddressVisibility() { + if (!document.getElementById('mode-plotter').checked && !document.getElementById('mode-harvester').checked) { + $('#controller_address_row').hide() + } else { + $('#controller_address_row').show() + } } function getRadioButtonValue(name) { var radios = document.getElementsByName(name); @@ -417,7 +426,7 @@

Machinaris Worker - Launch Config

{% include 'views/timezones_select.html' %}
-
+
Date: Thu, 15 Jul 2021 21:54:50 -0600 Subject: [PATCH 10/26] datatables.js --- web/actions/chiadog.py | 2 +- web/static/styles.css | 10 ++++++++++ web/templates/alerts.html | 12 ++++++++++-- web/templates/base.html | 6 +++++- web/templates/farming.html | 10 +++++++++- web/templates/plotting.html | 11 +++++++++-- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/web/actions/chiadog.py b/web/actions/chiadog.py index d78d0891..dbfe9f37 100644 --- a/web/actions/chiadog.py +++ b/web/actions/chiadog.py @@ -49,7 +49,7 @@ def save_config(farmer, blockchain, config): flash('Nice! Chiadog\'s config.yaml validated and saved successfully.', 'success') def get_notifications(): - return db.session.query(a.Alert).order_by(a.Alert.created_at.desc()).limit(25).all() + return db.session.query(a.Alert).order_by(a.Alert.created_at.desc()).all() def start_chiadog(farmer): app.logger.info("Starting Chiadog monitoring...") diff --git a/web/static/styles.css b/web/static/styles.css index fd993639..33306e04 100644 --- a/web/static/styles.css +++ b/web/static/styles.css @@ -83,3 +83,13 @@ body { ::-webkit-scrollbar-corner { background: transparent; } + +/** datatables.js pagination footer */ +.page-item.active .page-link { + background-color: lightgrey !important; + border: 1px solid black; +} +.page-link { + color: black !important; +} + diff --git a/web/templates/alerts.html b/web/templates/alerts.html index 5a25c58a..c99a2bbe 100644 --- a/web/templates/alerts.html +++ b/web/templates/alerts.html @@ -91,7 +91,7 @@ {% if notifications|length > 0 %}
- +
@@ -142,4 +142,12 @@
Expect at least a summary notification once daily as long as running above.< }) - {% endblock %} \ No newline at end of file + {% endblock %} + + {% block scripts %} + + {% endblock % \ No newline at end of file diff --git a/web/templates/base.html b/web/templates/base.html index a3db320a..d804b956 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -7,7 +7,7 @@ - + Machinaris {% if reload_seconds %} @@ -163,6 +163,10 @@ + + + + {% block scripts %}{% endblock %} \ No newline at end of file diff --git a/web/templates/farming.html b/web/templates/farming.html index 1f9df095..2fc9fd0e 100644 --- a/web/templates/farming.html +++ b/web/templates/farming.html @@ -113,7 +113,7 @@
-
Worker
+
{% for column in plots.columns %} @@ -147,4 +147,12 @@
+ {% endblock %} + + {% block scripts %} + {% endblock %} \ No newline at end of file diff --git a/web/templates/plotting.html b/web/templates/plotting.html index 48e31616..68d4e738 100644 --- a/web/templates/plotting.html +++ b/web/templates/plotting.html @@ -137,7 +137,7 @@
- +
@@ -207,5 +207,12 @@ }); }) + {% endblock %} - {% endblock %} \ No newline at end of file + {% block scripts %} + + {% endblock % \ No newline at end of file From 3685f396058756cbd64af64a4d892bf0a7966fbf Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Thu, 15 Jul 2021 22:01:26 -0600 Subject: [PATCH 11/26] Missing bracket. --- web/templates/alerts.html | 2 +- web/templates/plotting.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/templates/alerts.html b/web/templates/alerts.html index c99a2bbe..476ba5ae 100644 --- a/web/templates/alerts.html +++ b/web/templates/alerts.html @@ -150,4 +150,4 @@
Expect at least a summary notification once daily as long as running above.< $('#data').DataTable(); }); - {% endblock % \ No newline at end of file + {% endblock %} \ No newline at end of file diff --git a/web/templates/plotting.html b/web/templates/plotting.html index 68d4e738..26cb265b 100644 --- a/web/templates/plotting.html +++ b/web/templates/plotting.html @@ -215,4 +215,4 @@
$('#data').DataTable(); }); - {% endblock % \ No newline at end of file + {% endblock %} \ No newline at end of file From 516c9c066ddd1a4de4196a8768790b8176ca6c3c Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Fri, 16 Jul 2021 06:28:20 -0600 Subject: [PATCH 12/26] Fix for script ordering. Patch Chiadog to disable p --- scripts/chiadog_install.sh | 6 +++ web/routes.py | 2 - web/templates/alerts.html | 52 ++++++++++------------ web/templates/farming.html | 55 +++++++++++------------ web/templates/index.html | 18 +++++--- web/templates/logs.html | 1 - web/templates/plotting.html | 59 +++++++++++-------------- web/templates/settings/alerts.html | 65 +++++++++++++++------------- web/templates/settings/farming.html | 65 +++++++++++++++------------- web/templates/settings/plotting.html | 57 ++++++++++++------------ web/templates/settings/pools.html | 3 ++ web/templates/workers.html | 60 ++++++++++++------------- 12 files changed, 222 insertions(+), 221 deletions(-) diff --git a/scripts/chiadog_install.sh b/scripts/chiadog_install.sh index dd0f2174..114f8b0d 100644 --- a/scripts/chiadog_install.sh +++ b/scripts/chiadog_install.sh @@ -9,6 +9,12 @@ cd / git clone https://github.com/martomi/chiadog.git +# Temporary patch for spam about partial proofs +# https://github.com/martomi/chiadog/issues/252#issuecomment-877416135 + +cd /chiadog/src/chia_log/handlers/ +sed -i 's/FoundProofs(),//g' harvester_activity_handler.py + cd /chia-blockchain/ # Chia-blockchain needs PyYAML=5.4.1 but Chiadog wants exactly 5.4 diff --git a/web/routes.py b/web/routes.py index 9a7ef446..ce41a370 100644 --- a/web/routes.py +++ b/web/routes.py @@ -185,8 +185,6 @@ def settings_plotting(): if request.method == 'POST': selected_worker_hostname = request.form.get('worker') plotman.save_config(worker.get_worker_by_hostname(selected_worker_hostname), request.form.get("config")) - else: - flash('Automatically set your public key values below. Please review and save the config at least once!', 'message') workers_summary = worker.load_worker_summary() selected_worker = find_selected_worker(workers_summary, selected_worker_hostname) return render_template('settings/plotting.html', diff --git a/web/templates/alerts.html b/web/templates/alerts.html index 476ba5ae..1b5e71eb 100644 --- a/web/templates/alerts.html +++ b/web/templates/alerts.html @@ -2,27 +2,6 @@ {% block content %} - -
Alerts: Recent Notifications
@@ -123,8 +102,30 @@
Expect at least a summary notification once daily as long as running above.< {% endif %} + {% endblock %} + + {% block scripts %} - - {% endblock %} - - {% block scripts %} - {% endblock %} \ No newline at end of file diff --git a/web/templates/farming.html b/web/templates/farming.html index 2fc9fd0e..5f74bf25 100644 --- a/web/templates/farming.html +++ b/web/templates/farming.html @@ -2,35 +2,6 @@ {% block content %} - -
Farming: {{ farming.plot_count }} plots.
@@ -151,6 +122,32 @@ {% block scripts %} -
-
- {% include 'views/challenges.html' %} -
-
- {% endif %} - {% endblock %} \ No newline at end of file diff --git a/web/templates/logs.html b/web/templates/logs.html index 34ba6f5d..dde4e5d6 100644 --- a/web/templates/logs.html +++ b/web/templates/logs.html @@ -69,7 +69,6 @@ - diff --git a/web/templates/plotting.html b/web/templates/plotting.html index 26cb265b..fb5988a6 100644 --- a/web/templates/plotting.html +++ b/web/templates/plotting.html @@ -2,31 +2,6 @@ {% block content %} - -
Plotting Status: {{ plotting.display_status }} {% if plotting.display_status == 'Active' %} @@ -179,8 +154,34 @@ {% endif %} + {% endblock %} + + {% block scripts %} - {% endblock %} - - {% block scripts %} - {% endblock %} \ No newline at end of file diff --git a/web/templates/settings/alerts.html b/web/templates/settings/alerts.html index 4edacfa3..0711abcc 100644 --- a/web/templates/settings/alerts.html +++ b/web/templates/settings/alerts.html @@ -32,37 +32,6 @@ {% endwith %}
-
@@ -99,4 +68,38 @@
+ {% endblock %} + + {% block scripts %} + {% endblock %} \ No newline at end of file diff --git a/web/templates/settings/farming.html b/web/templates/settings/farming.html index ed01d0ce..253917d5 100644 --- a/web/templates/settings/farming.html +++ b/web/templates/settings/farming.html @@ -33,37 +33,6 @@ {% endwith %} -
@@ -100,4 +69,38 @@
+ {% endblock %} + + {% block scripts %} + {% endblock %} \ No newline at end of file diff --git a/web/templates/settings/plotting.html b/web/templates/settings/plotting.html index 9a7cb0b0..e1020dd2 100644 --- a/web/templates/settings/plotting.html +++ b/web/templates/settings/plotting.html @@ -32,33 +32,6 @@ {% endwith %} -
@@ -88,4 +61,34 @@
+ {% endblock %} + + {% block scripts %} + {% endblock %} \ No newline at end of file diff --git a/web/templates/settings/pools.html b/web/templates/settings/pools.html index 1317cc26..a5978946 100644 --- a/web/templates/settings/pools.html +++ b/web/templates/settings/pools.html @@ -135,6 +135,9 @@

chia plotnft - log output

{% endif %} + {% endblock %} + + {% block scripts %} -
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} @@ -44,15 +33,15 @@ {% if workers.workers|length > 0 %}
-
+
- - - - - + + + + + @@ -83,19 +72,6 @@ - - {% else %}
@@ -109,4 +85,28 @@
For more, see the Machinaris
HostnameSystem TypeLast Status Received AtLast Ping to WorkerLast Successful Ping to WorkerHostnameSystem TypeLast Status Received AtLast Ping to WorkerLast Successful Ping to Worker
- - - - - - - - - - - - {% for notification in notifications %} - - - - - - - - - {% endfor %} - -
WorkerBlockchainServiceNotificationRecorded AtPriority
{{notification.hostname}}{{notification.blockchain}}{{notification.service}}{{notification.message}}{{notification.created_at | datetimefilter}}{{notification.priority}}
-
+
+
+ + + + + + + + + + + + + + {% for notification in notifications %} + + + + + + + + + + {% endfor %} + +
+ + WorkerBlockchainServiceNotificationRecorded AtPriority
{{notification.hostname}}{{notification.blockchain}}{{notification.service}}{{notification.message}}{{notification.created_at | datetimefilter}}{{notification.priority}}
+
+
+
+ +
{% else %}
No notifications from Chiadog yet... so check back soon.
@@ -115,9 +127,9 @@
Expect at least a summary notification once daily as long as running above.< window.open("{{ url_for('logs') }}?log=alerts&hostname=" + hostname + "&blockchain=" + blockchain, 'Chiadog Log on ' + hostname, 'resizeable=yes,scrollbars=yes,height=' + height + ',width=' + width + ',top=' + top + ',left=' + left).focus(); } function MonitoringAction(hostname, service, action, status) { - $("#"+hostname+"_btn").prop("disabled", true); - $("#"+hostname+"_btn").html( - ' '+ hostname + ': ' + status + '...' + $("#" + hostname + "_btn").prop("disabled", true); + $("#" + hostname + "_btn").html( + ' ' + hostname + ': ' + status + '...' ); $('#chiadog-form').append(''); $('#chiadog-form').append(''); @@ -126,7 +138,8 @@
Expect at least a summary notification once daily as long as running above.< } $(document).ready(function () { $('#data').DataTable({ - "order": [[ 4, "desc" ]], + "order": [[5, "desc"]], + "columnDefs": [{ "orderable": false, targets: [0] }], }); $("#btnStart").click(function () { $(this).prop("disabled", true); @@ -142,6 +155,20 @@
Expect at least a summary notification once daily as long as running above.< ); $("#chiadog-form").submit(); }); + $("#btnRemove").click(function () { + $('#btnRemove').prop("disabled", true); + $('#btnRemove').html( + ` Removing...` + ); + $('#alerts-form').append(''); + $("#alerts-form").submit(); + }); }); + function checkPage(bx) { + for (var tbls = document.getElementsByTagName("table"), i = tbls.length; i--;) + for (var bxs = tbls[i].getElementsByTagName("input"), j = bxs.length; j--;) + if (bxs[j].type == "checkbox") + bxs[j].checked = bx.checked; + } {% endblock %} \ No newline at end of file From a69f29583fcbbebd2029c4391e84664b6fdabe13 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Tue, 20 Jul 2021 19:36:21 -0600 Subject: [PATCH 19/26] Try Plotman development stream. --- scripts/plotman_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/plotman_install.sh b/scripts/plotman_install.sh index 73fed0bf..00fc8b91 100644 --- a/scripts/plotman_install.sh +++ b/scripts/plotman_install.sh @@ -4,7 +4,7 @@ # cd /chia-blockchain -PLOTMAN_REPO_URL=https://github.com/ericaltendorf/plotman@main +PLOTMAN_REPO_URL=https://github.com/ericaltendorf/plotman@development from="${PLOTMAN_GIT_URL:-${PLOTMAN_REPO_URL}}" echo 'Installing Plotman from:${from}...' From dfd1a2c7d5e8252f08b3e6afae2445895c95c991 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Tue, 20 Jul 2021 20:02:17 -0600 Subject: [PATCH 20/26] New madmax settings. --- CHANGELOG.md | 3 ++- config/plotman.sample.yaml | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 497fbbcb..76736ef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.5.1] - 2021-07-? +## [0.5.1] - 2021-07-22 - Wizard on Workers page to create a Docker run/compose based on your settings. [Issue #97](https://github.com/guydavis/machinaris/issues/97) - Update to patch release of Chia 1.2.2, including a fix for harvester cache updates. See their [changelog for details](https://github.com/Chia-Network/chia-blockchain/releases/tag/1.2.2). +- Latest Madmax plotter with support for n_buckets3 and n_rmulti2 settings in Plotman. ## [0.5.0] - 2021-07-09 diff --git a/config/plotman.sample.yaml b/config/plotman.sample.yaml index 8d34700b..09926dab 100644 --- a/config/plotman.sample.yaml +++ b/config/plotman.sample.yaml @@ -103,15 +103,18 @@ plotting: # If you enable 'madmax', plot in *sequence* with very low tmpdir_max_jobs and global_max_jobs type: chia - # The chia plotter: https://github.com/Chia-Network/chia-blockchain chia: + # The stock plotter: https://github.com/Chia-Network/chia-blockchain k: 32 # k-size of plot, leave at 32 most of the time - e: False # Disable bitfield back sorting (default is True) + e: False # Use -e plotting option n_threads: 2 # Threads per job n_buckets: 128 # Number of buckets to split data into job_buffer: 3389 # Per job memory - # The madmax plotter: https://github.com/madMAx43v3r/chia-plotter + # If you enable madMAx, plot in *sequence* with very low tmpdir_max_jobs and global_max_jobs madmax: + # madMAx plotter: https://github.com/madMAx43v3r/chia-plotter n_threads: 4 # Default is 4, SLOWLY crank up if you have many cores n_buckets: 256 # Default is 256 + n_buckets3: 256 # Default is 256 + n_rmulti2: 1 # Default is 1 From 838b4b3d9aa59e746bd32495eb1779ae8c545c60 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Wed, 21 Jul 2021 11:58:13 -0600 Subject: [PATCH 21/26] Adding error display to Workers launch template. --- config/plotman.sample.yaml | 1 - scripts/chiadog_launch.sh | 2 +- web/templates/worker_launch.html | 56 +++++++++++++++++++------------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/config/plotman.sample.yaml b/config/plotman.sample.yaml index 09926dab..d2269136 100644 --- a/config/plotman.sample.yaml +++ b/config/plotman.sample.yaml @@ -111,7 +111,6 @@ plotting: n_buckets: 128 # Number of buckets to split data into job_buffer: 3389 # Per job memory - # If you enable madMAx, plot in *sequence* with very low tmpdir_max_jobs and global_max_jobs madmax: # madMAx plotter: https://github.com/madMAx43v3r/chia-plotter n_threads: 4 # Default is 4, SLOWLY crank up if you have many cores diff --git a/scripts/chiadog_launch.sh b/scripts/chiadog_launch.sh index 57d15188..898f2fc3 100644 --- a/scripts/chiadog_launch.sh +++ b/scripts/chiadog_launch.sh @@ -6,7 +6,7 @@ cp -f /machinaris/scripts/chiadog_notifier.sh /root/.chia/chiadog/notifier.sh && echo 'Starting Chiadog...' cd /chiadog chiadog_pids=$(pidof python3) -if [ ! -z $chiadog_pids ]; then +if [[ ! -z $chiadog_pids ]]; then kill $chiadog_pids fi /chia-blockchain/venv/bin/python3 -u main.py --config /root/.chia/chiadog/config.yaml > /root/.chia/chiadog/logs/chiadog.log 2>&1 & diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index 99641655..7a3448a8 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -69,11 +69,11 @@
`; new_vol_row = new_vol_row.replaceAll('0', cur_vols) $('#volumes').append(new_vol_row); - setTimeout(updateDocker, 1000); + setTimeout(updateDocker, 1000); } function volumeRemove() { $('.volume').last().remove() - setTimeout(updateDocker, 1000); + setTimeout(updateDocker, 1000); } function togglePlottingKeysVisibility() { if (document.getElementById('mode-plotter').checked) { @@ -92,7 +92,7 @@ toggleControllerAddressVisibility(); } function toggleControllerAddressVisibility() { - if (!document.getElementById('mode-plotter').checked && !document.getElementById('mode-harvester').checked) { + if (!document.getElementById('mode-plotter').checked && !document.getElementById('mode-harvester').checked) { $('#controller_address_row').hide() } else { $('#controller_address_row').show() @@ -127,6 +127,7 @@ updateDockerCompose(); } function updateDockerRun() { + var errors = []; var os = getRadioButtonValue('os') if (os == 'windows') { line_end = ' `\n'; @@ -158,8 +159,11 @@ cmd += ' -v ' + document.getElementById("appdata").value + ':/root/.chia' + line_end; var cur_vols = $('#volumes').children().length var plots_dir = [] - $('#volumes').children().each( (index, element) => { + $('#volumes').children().each((index, element) => { volume_host_path = document.getElementById("volume_host_path" + index).value; + if (volume_host_path.endsWith(':')) { + errors.push("Invalid host path ending with colon. Try adding a slash to the end like this " + volume_host_path + '/'); + } volume_container_path = document.getElementById("volume_container_path" + index).value; cmd += ' -v ' + volume_host_path + ':' + volume_container_path + line_end; if ($('#volume_type' + index).val() == 'plots') { @@ -175,7 +179,7 @@ if (document.getElementById("blockchain-flax").checked) { cmd += ' -e flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; } - } + } if (document.getElementById('mode-plotter').checked) { if (mode) { mode += ',plotter'; @@ -203,7 +207,7 @@ blockchains += ',flax' } cmd += ' -e blockchains=' + blockchains + line_end; - var auto_plot = getRadioButtonValue('auto_plot'); + var auto_plot = getRadioButtonValue('auto_plot'); if (auto_plot == "true") { cmd += ' -e AUTO_PLOT=' + auto_plot + line_end; } @@ -216,12 +220,18 @@ } cmd += ' ghcr.io/guydavis/machinaris'; $('#run').html(cmd); + if (errors.length > 0) { + $('#errors').html(errors); + $('#errors').show(); + } else { + $('#errors').hide(); + } } function updateDockerCompose() { var line_end = ' \n'; var os = getRadioButtonValue('os') - cmd = "version: '3.9'" + line_end; - cmd += "services:" + line_end; + cmd = "version: '3.9'" + line_end; + cmd += "services:" + line_end; cmd += " machinaris:" + line_end; cmd += " image: ghcr.io/guydavis/machinaris" + line_end; cmd += " container_name: machinaris" + line_end; @@ -237,7 +247,7 @@ cmd += ' - ' + document.getElementById("appdata").value + ':/root/.chia' + line_end; var cur_vols = $('#volumes').children().length var plots_dir = [] - $('#volumes').children().each( (index, element) => { + $('#volumes').children().each((index, element) => { volume_host_path = document.getElementById("volume_host_path" + index).value; volume_container_path = document.getElementById("volume_container_path" + index).value; cmd += ' - ' + volume_host_path + ':' + volume_container_path + line_end; @@ -255,7 +265,7 @@ if (document.getElementById("blockchain-flax").checked) { cmd += ' - flax_farmer_port=' + document.getElementById("flax_farmer_port").value + line_end; } - } + } if (document.getElementById('mode-plotter').checked) { if (mode) { mode += ',plotter'; @@ -283,7 +293,7 @@ blockchains += ',flax' } cmd += ' - blockchains=' + blockchains + line_end; - var auto_plot = getRadioButtonValue('auto_plot'); + var auto_plot = getRadioButtonValue('auto_plot'); if (auto_plot == "true") { cmd += ' - AUTO_PLOT=' + auto_plot + line_end; } @@ -314,7 +324,7 @@

Machinaris Worker - Launch Config

-

+
@@ -375,8 +385,8 @@

Machinaris Worker - Launch Config

- +
@@ -428,9 +438,9 @@

Machinaris Worker - Launch Config

- - + +
@@ -440,9 +450,9 @@

Machinaris Worker - Launch Config

- - + +
@@ -534,14 +544,16 @@

Volume Mounts

- +

Docker Run


     
- +

Docker Compose

From c40e43f3a85f04239d25e9eb892040fb838fbdb1 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Wed, 21 Jul 2021 14:10:09 -0600 Subject: [PATCH 22/26] Require users to enter paths. --- web/templates/worker_launch.html | 62 +++++++++++++++++++------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/web/templates/worker_launch.html b/web/templates/worker_launch.html index 7a3448a8..be8cad54 100644 --- a/web/templates/worker_launch.html +++ b/web/templates/worker_launch.html @@ -49,12 +49,12 @@ var new_vol_row = `
-
-
@@ -110,24 +110,39 @@ var os = getRadioButtonValue('os') if (os == 'windows') { document.getElementById('appdata').value = '${APPDATA}/.machinaris'; - document.getElementById('volume_host_path0').value = "C:/my_chia_plots"; - document.getElementById('volume_host_path1').value = "C:/my_chia_plotting"; + document.getElementById('volume_host_path0').placeholder = "C:/my_chia_plots"; + document.getElementById('volume_host_path1').placeholder = "C:/my_chia_plotting"; } else if (os == 'macintosh') { document.getElementById('appdata').value = '~/.machinaris'; - document.getElementById('volume_host_path0').value = "/Volumes/disk1"; - document.getElementById('volume_host_path1').value = "/Volumes/temp1"; + document.getElementById('volume_host_path0').placeholder = "/Volumes/disk1"; + document.getElementById('volume_host_path1').placeholder = "/Volumes/temp1"; } else { document.getElementById('appdata').value = '~/.machinaris'; - document.getElementById('volume_host_path0').value = "/mnt/disk1"; - document.getElementById('volume_host_path1').value = "/mnt/temp1"; + document.getElementById('volume_host_path0').placeholder = "/mnt/disk1"; + document.getElementById('volume_host_path1').placeholder = "/mnt/temp1"; } } function updateDocker() { - updateDockerRun(); - updateDockerCompose(); - } - function updateDockerRun() { var errors = []; + run = updateDockerRun(errors); + compose = updateDockerCompose(errors); + if (errors.length > 0) { + msg = "
    "; + for (let i = 0; i < errors.length; i++) { + msg += "
  • " + errors[i] + "
  • "; + } + msg += "
"; + $('#errors').html(msg); + $('#errors').show(); + $('#run').html(''); + $('#compose').html(''); + } else { + $('#run').html(run); + $('#compose').html(compose); + $('#errors').hide(); + } + } + function updateDockerRun(errors) { var os = getRadioButtonValue('os') if (os == 'windows') { line_end = ' `\n'; @@ -161,10 +176,15 @@ var plots_dir = [] $('#volumes').children().each((index, element) => { volume_host_path = document.getElementById("volume_host_path" + index).value; + volume_container_path = document.getElementById("volume_container_path" + index).value; if (volume_host_path.endsWith(':')) { errors.push("Invalid host path ending with colon. Try adding a slash to the end like this " + volume_host_path + '/'); + } + if (!volume_host_path) { + errors.push("Empty host path provided for volume at '" + volume_container_path + "'. Please provide a host path."); + } else if (!volume_container_path) { + errors.push("Empty container path provided for volume at '" + volume_host_path + "'. Please provide a container path."); } - volume_container_path = document.getElementById("volume_container_path" + index).value; cmd += ' -v ' + volume_host_path + ':' + volume_container_path + line_end; if ($('#volume_type' + index).val() == 'plots') { plots_dir.push(volume_container_path) @@ -219,13 +239,7 @@ } } cmd += ' ghcr.io/guydavis/machinaris'; - $('#run').html(cmd); - if (errors.length > 0) { - $('#errors').html(errors); - $('#errors').show(); - } else { - $('#errors').hide(); - } + return cmd; } function updateDockerCompose() { var line_end = ' \n'; @@ -308,7 +322,7 @@ cmd += ' - 6885' + line_end; } } - $('#compose').html(cmd); + return cmd; } $(document).ready(function () { $('#plotting_keys_row').hide() @@ -324,7 +338,7 @@

Machinaris Worker - Launch Config

- +
@@ -491,7 +505,7 @@

Volume Mounts

-
@@ -512,7 +526,7 @@

Volume Mounts

-
From ebbe673362bc837959061805e1e1dd24c3ac92a0 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Wed, 21 Jul 2021 17:10:43 -0600 Subject: [PATCH 23/26] Due to user plotting with other keys for a friend, only replace if original placeholder is present. --- config/plotman.sample.yaml | 12 ++++++------ web/actions/plotman.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/plotman.sample.yaml b/config/plotman.sample.yaml index d2269136..adc98c3d 100644 --- a/config/plotman.sample.yaml +++ b/config/plotman.sample.yaml @@ -92,12 +92,12 @@ scheduling: # Configure the plotter. See: https://github.com/guydavis/machinaris/wiki/Plotman#plotting plotting: - # Your farmer public key is always required for plotting - # farmer_pk: YOUR_FARMER_PUBLIC_KEY (always required) - # Your pool public key is only required for solo plotting, else comment it out! - #pool_pk: YOUR_POOL_PUBLIC_KEY (comment this out if portable pool plotting) - # Your pool contract address is only required for portable pool plotting, else comment it out! - #pool_contract_address: YOUR_POOL_CONTRACT_ADDRESS (comment this out if solo plotting) + # See Keys page, for 'Farmer public key' value + farmer_pk: REPLACE_WITH_THE_REAL_VALUE + # ONLY FOR OLD SOLO PLOTS, COMMENT OUT IF PORTABLE PLOTTING!!! + pool_pk: REPLACE_WITH_THE_REAL_VALUE + # See 'Settings | Pools' page, for 'P2 singleton address' value, UNCOMMENT IF PORTABLE PLOTTING!!! + #pool_contract_address: REPLACE_WITH_THE_REAL_VALUE # If you enable 'chia', plot in *parallel* with higher tmpdir_max_jobs and global_max_jobs # If you enable 'madmax', plot in *sequence* with very low tmpdir_max_jobs and global_max_jobs diff --git a/web/actions/plotman.py b/web/actions/plotman.py index 6eec7a60..8a375466 100644 --- a/web/actions/plotman.py +++ b/web/actions/plotman.py @@ -157,15 +157,15 @@ def load_config_replacements(): farmer_pk = load_key_pk('Farmer') if farmer_pk: #app.logger.info("FARMER_PK: {0}".format(farmer_pk)) - replacements.append([ 'farmer_pk:.*$', 'farmer_pk: '+ farmer_pk]) + replacements.append([ 'farmer_pk:\s+REPLACE_WITH_THE_REAL_VALUE.*$', 'farmer_pk: '+ farmer_pk]) pool_pk = load_key_pk('Pool') if pool_pk: #app.logger.info("POOL_PK: {0}".format(pool_pk)) - replacements.append([ 'pool_pk:.*$', 'pool_pk: '+ pool_pk]) + replacements.append([ 'pool_pk:\s+REPLACE_WITH_THE_REAL_VALUE.*$', 'pool_pk: '+ pool_pk]) pool_contract_address = load_pool_contract_address() if pool_contract_address: #app.logger.info("POOL_CONTRACT_ADDRESS: {0}".format(pool_contract_address)) - replacements.append([ 'pool_contract_address:.*$', 'pool_contract_address: '+ pool_contract_address]) + replacements.append([ 'pool_contract_address:\s+REPLACE_WITH_THE_REAL_VALUE.*$', 'pool_contract_address: '+ pool_contract_address]) return replacements def load_config(plotter): From 9a542768d73154829713a408e4238603f7a6d890 Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Wed, 21 Jul 2021 18:56:38 -0600 Subject: [PATCH 24/26] Even more code for conditional replacement of plotting keys. --- web/actions/plotman.py | 11 +++++++++-- web/routes.py | 4 +++- web/templates/settings/plotting.html | 11 ++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/web/actions/plotman.py b/web/actions/plotman.py index 8a375466..aacb1486 100644 --- a/web/actions/plotman.py +++ b/web/actions/plotman.py @@ -177,11 +177,18 @@ def load_config(plotter): app.logger.info(traceback.format_exc()) lines = [] config = utils.send_get(plotter, "/configs/plotting", debug=False).content.decode('utf-8') + replaces = 0 for line in config.splitlines(): for replacement in replacements: - line = re.sub(replacement[0], replacement[1], line) + (line, num_replaces) = re.subn(replacement[0], replacement[1], line) + replaces += num_replaces lines.append(line) - return '\n'.join(lines) + if replaces > 0: + #app.logger.info("Return true for replaced.") + return [ True, '\n'.join(lines) ] + else: + #app.logger.info("Return false for replaced.") + return [ False, '\n'.join(lines) ] def save_config(plotter, config): try: # Validate the YAML first diff --git a/web/routes.py b/web/routes.py index 63474bd9..2a1711b2 100644 --- a/web/routes.py +++ b/web/routes.py @@ -246,7 +246,9 @@ def views_settings_config(path): elif config_type == "farming": response = make_response(chia.load_config(w, request.args.get('blockchain')), 200) elif config_type == "plotting": - response = make_response(plotman.load_config(w), 200) + [replaced, config] = plotman.load_config(w) + response = make_response(config, 200) + response.headers.set('ConfigReplacementsOccurred', replaced) else: abort("Unsupported config type: {0}".format(config_type), 400) response.mimetype = "application/x-yaml" diff --git a/web/templates/settings/plotting.html b/web/templates/settings/plotting.html index a677e07e..9e8cb795 100644 --- a/web/templates/settings/plotting.html +++ b/web/templates/settings/plotting.html @@ -32,6 +32,7 @@ {% endwith %}
+
@@ -66,13 +67,21 @@ {% block scripts %}