@@ -36,7 +36,7 @@ def upgrade
3636 log ( "*** Please be patient, next steps might take a while ***" )
3737 log ( "********************************************************" )
3838
39- if web_server . workers . size < min_workers
39+ if web_server . workers . size <= min_workers
4040 log ( "ABORTING, you do not have enough #{ server_name } workers running" )
4141 raise "Not enough workers"
4242 end
@@ -60,63 +60,53 @@ def upgrade
6060 web_server . scale_down_workers ( num_workers_spun_down )
6161 end
6262
63- if ENV [ "UNICORN_SIDEKIQS" ] . to_i > 0
64- if web_server . pause_sidekiq
65- log "Stopping job queue to reclaim memory, master pid is #{ web_server . master_pid } "
66- end
67- end
63+ web_server . pause_sidekiq
6864
6965 # HEAD@{upstream} is just a fancy way how to say origin/main (in normal case)
7066 # see http://stackoverflow.com/a/12699604/84283
7167 @repos . each_with_index do |repo , index |
7268 # We automatically handle renames from `master` -> `main`
7369 log ( "Doing git stuff…" )
7470 sleep 5
75- # if repo.upstream_branch == "origin/master" && repo.tracking_ref == "origin/main"
76- # log "Branch has changed to #{repo.tracking_ref}"
77- #
78- # # Just in case `main` exists locally but is not used. Perhaps it was fetched?
79- # if repo.has_local_main?
80- # run "cd #{repo.path} && git checkout main"
81- # else
82- # run "cd #{repo.path} && git branch -m master main"
83- # end
84- #
85- # run "cd #{repo.path} && git fetch origin --tags --force"
86- # run "cd #{repo.path} && git branch -u origin/main main"
87- # run("cd #{repo.path} && git reset --hard HEAD@{upstream}")
88- # else
89- # run("cd #{repo.path} && git fetch --tags --prune-tags --prune --force")
90- #
91- # if repo.detached_head?
92- # run("cd #{repo.path} && git reset --hard")
93- # run("cd #{repo.path} && git -c advice.detachedHead=false checkout #{repo.tracking_ref}")
94- # else
95- # run("cd #{repo.path} && git reset --hard HEAD@{upstream}")
96- # end
97- # end
71+ if repo . upstream_branch == "origin/master" && repo . tracking_ref == "origin/main"
72+ log "Branch has changed to #{ repo . tracking_ref } "
73+
74+ # Just in case `main` exists locally but is not used. Perhaps it was fetched?
75+ if repo . has_local_main?
76+ run "cd #{ repo . path } && git checkout main"
77+ else
78+ run "cd #{ repo . path } && git branch -m master main"
79+ end
80+
81+ run "cd #{ repo . path } && git fetch origin --tags --force"
82+ run "cd #{ repo . path } && git branch -u origin/main main"
83+ run ( "cd #{ repo . path } && git reset --hard HEAD@{upstream}" )
84+ else
85+ run ( "cd #{ repo . path } && git fetch --tags --prune-tags --prune --force" )
86+
87+ if repo . detached_head?
88+ run ( "cd #{ repo . path } && git reset --hard" )
89+ run ( "cd #{ repo . path } && git -c advice.detachedHead=false checkout #{ repo . tracking_ref } " )
90+ else
91+ run ( "cd #{ repo . path } && git reset --hard HEAD@{upstream}" )
92+ end
93+ end
9894
9995 percent ( 20 * ( index + 1 ) / @repos . size )
10096 end
10197
102- log ( "Installing stuff…" )
103- sleep 5
104- # run("bundle install --retry 3 --jobs 4")
105- # run("if [ -f yarn.lock ]; then yarn install; else CI=1 pnpm install; fi")
106- # begin
107- # run("LOAD_PLUGINS=0 bundle exec rake plugin:pull_compatible_all")
108- # rescue RuntimeError
109- # log "Unable checkout compatible plugin versions"
110- # end
98+ run ( "bundle install --retry 3 --jobs 4" )
99+ run ( "if [ -f yarn.lock ]; then yarn install; else CI=1 pnpm install; fi" )
100+ begin
101+ run ( "LOAD_PLUGINS=0 bundle exec rake plugin:pull_compatible_all" )
102+ rescue RuntimeError
103+ log "Unable checkout compatible plugin versions"
104+ end
111105 percent ( 30 )
112- # run("SKIP_POST_DEPLOYMENT_MIGRATIONS=1 bundle exec rake multisite:migrate")
106+ run ( "SKIP_POST_DEPLOYMENT_MIGRATIONS=1 bundle exec rake multisite:migrate" )
113107 percent ( 40 )
114108 log ( "*** Bundling assets. This will take a while *** " )
115- # run("bundle exec rake themes:update assets:precompile")
116- 30 . times do |i |
117- log ( "." * i )
118- sleep 1
119- end
109+ run ( "bundle exec rake themes:update assets:precompile" )
120110
121111 using_s3_assets =
122112 ENV [ "DISCOURSE_USE_S3" ] && ENV [ "DISCOURSE_S3_BUCKET" ] && ENV [ "DISCOURSE_S3_CDN_URL" ]
@@ -129,11 +119,11 @@ def upgrade
129119
130120 # Flush nginx cache here - this is not critical, and the rake task may not exist yet - ignore failures here.
131121 percent ( 85 )
132- # begin
133- # run("bundle exec rake assets:flush_sw")
134- # rescue RuntimeError
135- # log "WARNING: Unable to flush service worker file"
136- # end
122+ begin
123+ run ( "bundle exec rake assets:flush_sw" )
124+ rescue RuntimeError
125+ log "WARNING: Unable to flush service worker file"
126+ end
137127
138128 percent ( 90 )
139129 log ( "Running post deploy migrations" )
0 commit comments