Skip to content
Open
1 change: 1 addition & 0 deletions .jujuignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Makefile
.github/
.tox/
*__pycache__*
*.rock
10 changes: 6 additions & 4 deletions discourse_rock/patches/sigterm.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rb
index fd2bf2ae0e..7e6429c544 100644
--- a/config/unicorn.conf.rb
+++ b/config/unicorn.conf.rb
@@ -62,6 +62,15 @@ check_client_connection false

initialized = false
before_fork do |server, worker|
+ Signal.trap 'TERM' do
Expand All @@ -15,10 +17,10 @@
+
unless initialized
Discourse.preload_rails!

@@ -299,6 +308,9 @@ before_fork do |server, worker|
Discourse.before_fork
@@ -193,6 +202,9 @@ before_fork do |server, worker|
end

after_fork do |server, worker|
+ Signal.trap 'TERM' do
+ puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
Expand Down
22 changes: 11 additions & 11 deletions discourse_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ parts:
- zlib1g-dev
build-environment:
- ARCH: "x64"
- NODE_VERSION: "18.18.2"
- NODE_VERSION: "22.9.0"
- RAILS_ENV: "production"
- RUBY_INSTALL_VERSION: "0.9.3"
- RUBY_VERSION: "3.2.6"
- YARN_VERSION: "1.22.19"
- RUBY_INSTALL_VERSION: "0.10.1"
- RUBY_VERSION: "3.3.8"
- PNPM_VERSION: "9.15.0"
override-build: |
node_uri="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.gz"
curl -Ls $node_uri | tar xzf - -C $CRAFT_OVERLAY/ --skip-old-files --no-same-owner --strip-components=1
yarn_uri="https://github.com/yarnpkg/yarn/releases/download/v${YARN_VERSION}/yarn-v${YARN_VERSION}.tar.gz"
curl -Ls $yarn_uri | tar xzf - -C $CRAFT_OVERLAY/ --skip-old-files --no-same-owner --strip-components=1
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=${PNPM_VERSION} SHELL=bash sh -
$CRAFT_OVERLAY/usr/bin/node $CRAFT_OVERLAY/usr/bin/npm install --verbose --prefix $CRAFT_OVERLAY/usr/local/ --global terser
$CRAFT_OVERLAY/usr/bin/node $CRAFT_OVERLAY/usr/bin/npm install --verbose --prefix $CRAFT_OVERLAY/usr/local/ --global uglify-js
$CRAFT_OVERLAY/usr/bin/node $CRAFT_OVERLAY/usr/bin/npm install --verbose --prefix $CRAFT_OVERLAY/usr/local/ --global svgo
$CRAFT_OVERLAY/usr/bin/node $CRAFT_OVERLAY/usr/bin/npm install --verbose --prefix $CRAFT_OVERLAY/usr/local/ --global pnpm@9
ruby_install_uri="https://github.com/postmodern/ruby-install/releases/download/v${RUBY_INSTALL_VERSION}/ruby-install-${RUBY_INSTALL_VERSION}.tar.gz"
curl -fLO $ruby_install_uri
tar -xzvf ruby-install-${RUBY_INSTALL_VERSION}.tar.gz
Expand All @@ -64,7 +65,7 @@ parts:
plugin: dump
source: https://github.com/discourse/discourse.git
source-depth: 1
source-tag: v3.3.0
source-tag: v3.4.7
source-type: git
override-build: |
craftctl default
Expand Down Expand Up @@ -125,7 +126,7 @@ parts:
plugin: dump
after: [discourse, bundler-config]
source: https://github.com/discourse/discourse-prometheus.git
source-commit: b1b899ca995783ef5eba90c35dbfc120a2949c38
source-commit: a1e0ba671e13ceb9541a4d62d3ff7d206393d438
source-depth: 1
override-build: |
craftctl default
Expand Down Expand Up @@ -184,7 +185,6 @@ parts:
- git
after: [discourse, patches]
override-stage: |
git -C srv/discourse/app apply patches/db_migrations.patch
git -C srv/discourse/app apply patches/lp1903695.patch
git -C srv/discourse/app apply patches/discourse-charm.patch
git -C srv/discourse/app apply patches/sigterm.patch
Expand Down Expand Up @@ -234,7 +234,7 @@ parts:
bin/bundle install --gemfile="plugins/discourse-solved/Gemfile"
bin/bundle install --gemfile="plugins/discourse-templates/Gemfile"
bin/bundle install --gemfile="plugins/discourse-chat-integration/Gemfile"
yarn install --immutable
/root/.local/share/pnpm/pnpm install
discourse-precompile-assets:
plugin: nil
after: [apply-patches, setup]
Expand All @@ -250,7 +250,7 @@ parts:
su - postgres -c "psql -c \"CREATE DATABASE discourse;\"" || echo "Could not create database, maybe it already exists."
su - postgres -c "psql -c \"CREATE USER discourse WITH PASSWORD 'discourse';\"" || echo "Could not create user, maybe it already exists."
su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE discourse TO discourse;\""
PATH=$PATH:${CRAFT_PRIME}/usr/bin:${CRAFT_PRIME}/usr/local/bin RAILS_ENV=production DISCOURSE_DB_HOST=127.0.0.1 DISCOURSE_DB_PASSWORD=discourse bundle exec rake assets:precompile
PATH=$PATH:${CRAFT_PRIME}/usr/bin:${CRAFT_PRIME}/usr/local/bin RAILS_ENV=production DISCOURSE_DB_HOST=127.0.0.1 DISCOURSE_DB_PASSWORD=discourse SKIP_EMBER_CLI_COMPILE=1 bundle exec rake assets:precompile
# Fix the symbolic links.
find . -lname "${CRAFT_PRIME}/srv/discourse/*" -exec bash -c 'ln -snf "$(readlink "$1" | sed "s~${CRAFT_PRIME}~~")" "$1" ' sh {} \;
perms:
Expand Down
Loading