Rebuild failure - skipping "after_assets_precompile" section of app.yml

I just did a ./launcher rebuild app—no changes to system-related files. I am now stuck on the discourse blinking dots.

I checked the following:

  • The docker ps shows the discourse app image (seems normal).
  • Top command shows activity (seems normal)
  • I can view the sidekiq status (seems normal)

So, I rebuilt the app again.

Same results.

I tried using Safe-mode. Everything turned off. No change. I am still receiving the blinking dots screen.

I reviewed every line of the source code. I show I have four js files that are not available. They are:

There are numerous missing javascript files. These were the first ones found.

Initial review:

  • The files are not available via my CDN delivery.
  • The CDN pulls from my S3 bucket.
  • The files are not in my S3 bucket where all other assets are stored.

Looking at the rebuild results, I can see the following.

  1. The 4 files were created and written to public/assets/ with a js file extension.
  2. The 4 files were compressed and saved with a br.js file extension.

Checking my server:

  1. All 4 .js files are available on my server
  2. The .br.js files are not available on my server
  3. The .br.js files are not on my S3 bucket

Going through the rebuild results, It appears the after_assets_precompile activity is not happening on my rebuilds. I can manually run a rake s3:upload_assets and the assets are migrated to S3 and everything works well.

I have checked the following:

  1. my yml file passes checks for proper formatting.

What can I check to determine why the after_assets_precompile is not processing as part of the rebuild?

note: I am running: 3.4.0.beta4-dev - 6a50b3d4b4

1 Like

Did you add the stanza to upload assets?

Configure an S3 compatible object storage provider for uploads

You can find that rake task there and then run it from inside the container (to save the time of a rebuild). And then do a rebuild once you edit your yml file.

S3 has been up and running on the site for 43 days. The rake commands were placed there as part of the S3 install.

The site has been rebuilt at least 30 times. I have added additional plugins and components along the way. This would indicate that .js files have been added and populated to the S3 bucket.

The S3 component has been working great. This is the first time I have had any issues with files not being migrated to S3.

What can I investigate to understand why the files were not moved?

Does anyone know what could cause the after_assets_precompile not to run?

1 Like

Help!

On rebuild, the process skips the following section in the app.yml file:

after_assets_precompile:
  - exec:
      cd: $home
      cmd:
        - sudo -E -u discourse bundle exec rake s3:upload_assets
        - sudo -E -u discourse bundle exec rake s3:expire_missing_assets

Immediately after rebuild, I can manually process the commands via:

./launcher enter app
rake s3:upload_assets
rake s3:expire_missing_assets

The commands run and process the required files to S3.

I have added an echo command to the after_assets_precompile code.

      cmd:
        - echo "Beginning of precompile commands"
        - sudo -E -u discourse bundle exec rake s3:upload_

The echo statement never appears in the rebuild output.

The rebuild step processes the steps before and after this section in the app.yml file. It processes all plugins and custom commands.

I have taken the following steps to try and resolve:

  1. Removed all plugins
  2. Disabled all components
  3. Reviewed all the discourse log files. Did not find any errors indicated.
  4. Reviewed base system log files. Did not find any errors indicated.

Does anyone have a clue why the rebuild process would skip this section?

As a test, I moved the after_assets_precompile commands to the custom command section.

run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  ## command to password protect the website during work. remove for production.
  - exec:
      cd: $home
      cmd:
        - echo "Beginning of precompile commands"
        - sudo -E -u discourse bundle exec rake s3:upload_assets
        - sudo -E -u discourse bundle exec rake s3:expire_missing_assets
  - exec: echo "End of custom commands"

The commands worked without any issues. This rules out environmental access or security issues.

The launcher process is skipping the after_assets_precompile code during the rebuild.

Any one have a clue?

1 Like

No clue, but I rebuilded about 4 hours ago without any issues.

1 Like

Maybe you have a whitespace or indentation error in your yml file. Search for a validator and check: [validate yaml]

this should not be a top-level key, this should be under hooks, e.g.:

hooks:
  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets
          - sudo -E -u discourse bundle exec rake s3:expire_missing_assets
3 Likes

That was listed in the first post. app.yml was validated for proper indentations.

1 Like

@supermathie - you are terrific with incredible eyesight. You were able to see that the code was not indented by two spaces. And only from a single snippet versus the more extensive section. Thank you.

I added the two spaces, and that solved the problem.

I had previously run app.yml through a yml checker. The testing tool told me the file was structurally sound. It could not tell me it was functionally wrong.

The correct code snippet should be:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-adplugin
          - git clone https://github.com/discourse/discourse-affiliate
          - git clone https://github.com/discourse/discourse-subscriptions
          - git clone https://github.com/discourse/discourse-yearly-review
          - git clone https://github.com/discourse/discourse-whos-online
          - git clone https://github.com/discourse/discourse-data-explorer
  # set internal files for cdn
  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - echo "Beginning of precompile commands"
          - sudo -E -u discourse bundle exec rake s3:upload_assets
          - sudo -E -u discourse bundle exec rake s3:expire_missing_assets

To document the app.yml file. The only top-level keys are:

  • templates:
  • params:
  • env:
  • volumes:
  • hooks:
  • run:

Everything else should be indented.

The simplest of errors can be the most frustrating. Six hours of my life were lost for two spaces.

My kingdom for two spaces.

2 Likes

This happens to me all the time.

My other favorite is editing the wrong file, or the right file on the wrong computer.

2 Likes