This repository was archived by the owner on Mar 20, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +35
-109
lines changed Expand file tree Collapse file tree 6 files changed +35
-109
lines changed Original file line number Diff line number Diff line change 6
6
include Clockwork
7
7
8
8
9
- every ( 1 . day , 'award:activate:active' , at : '00:00' ) { }
9
+ # Runs as 1:01 AM Pacific
10
+ every ( 1 . day , 'award:activate:active' , at : '01:01' ) do
11
+ ActivatePendingUsersWorker . perform_async
12
+ end
13
+
10
14
every ( 1 . day , 'award:fresh:stale' , at : '00:00' ) { }
11
15
every ( 1 . day , 'cleanup:protips:associate_zombie_upvotes' , at : '00:00' ) { }
12
16
every ( 1 . day , 'clear_expired_sessions' , at : '00:00' ) { }
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ def banned?
139
139
def activate
140
140
UserActivateWorker . perform_async ( id )
141
141
end
142
-
142
+
143
143
def activate!
144
144
# TODO: Switch to update, failing validations?
145
145
update_attributes! ( state : ACTIVE , activated_on : DateTime . now )
@@ -166,8 +166,6 @@ def oldest_achievement_since_last_visit
166
166
badges . where ( "badges.created_at > ?" , last_request_at ) . order ( 'badges.created_at ASC' ) . last
167
167
end
168
168
169
-
170
-
171
169
def company_name
172
170
team . try ( :name ) || company
173
171
end
@@ -177,7 +175,6 @@ def profile_url
177
175
avatar_url
178
176
end
179
177
180
-
181
178
def can_be_refreshed?
182
179
( achievements_checked_at . nil? || achievements_checked_at < 1 . hour . ago )
183
180
end
Original file line number Diff line number Diff line change
1
+ class ActivatePendingUsersWorker
2
+ include Sidekiq ::Worker
3
+ sidekiq_options queue : :critical
4
+
5
+
6
+ def perform
7
+ # Spawning possibly many thousands
8
+ # of workers the order doesn't really matter
9
+ # but would like to spread their execution
10
+ # over the next hour to avoid overloading
11
+ # the database.
12
+ delay = 0
13
+ User . pending . find_each ( batch_size : 100 ) do |user |
14
+ UserActivateWorker . perform_in ( delay . minutes , user . id )
15
+ delay = delay + Random . rand ( 0 ..59 )
16
+ end
17
+ end
18
+ end
Original file line number Diff line number Diff line change 1
- # UserActivateWorker
2
1
class UserActivateWorker
3
2
include Sidekiq ::Worker
4
3
sidekiq_options queue : :high
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /usr/ bin/env bash
2
2
3
3
# Define session name
4
4
5
5
SESSION=coderwall
6
6
7
7
# Go to working directory
8
8
9
- cd ~ /assemblymade/coderwall
9
+ # cd ~/assemblymade/coderwall
10
10
11
11
vagrant up --no-provision
12
12
@@ -27,7 +27,8 @@ tmux -2 new-session -d -s $SESSION
27
27
# Create windows
28
28
tmux new-window -t $SESSION :1 -n " code"
29
29
tmux new-window -t $SESSION :2 -n " web"
30
- tmux new-window -t $SESSION :3 -n " background jobs"
30
+ tmux new-window -t $SESSION :3 -n " sidekiq"
31
+ tmux new-window -t $SESSION :4 -n " clock"
31
32
32
33
# Define window roles
33
34
@@ -50,12 +51,17 @@ tmux select-pane -t 0
50
51
# tmux send-keys "clear ; env bin/rails server webrick -p3000" C-m
51
52
tmux send-keys " clear ; bundle exec puma -C ./config/puma.rb" C-m
52
53
53
- # Background Jobs
54
+ # Sidekiq
54
55
tmux select-window -t $SESSION :3
55
-
56
56
tmux select-pane -t 0
57
57
tmux send-keys " clear ; bundle exec sidekiq -C ./config/sidekiq.yml" C-m
58
58
59
+ # Clock
60
+ tmux select-window -t $SESSION :4
61
+ tmux select-pane -t 0
62
+ tmux send-keys " clear ; bundle exec clockwork app/clock.rb" C-m
63
+
64
+
59
65
# Set the initial working window
60
66
tmux select-window -t $SESSION :1
61
67
You can’t perform that action at this time.
0 commit comments