You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it"starts a new container if not already running"do
112
+
defcontroller.setup(container)
113
+
container.spawndo |instance|
114
+
instance.ready!
115
+
sleep
116
+
end
117
+
end
118
+
119
+
expect(controller).not.tobe(:running?)
120
+
121
+
controller.restart
122
+
123
+
expect(controller).tobe(:running?)
124
+
expect(controller.container).not.tobe_nil
125
+
ensure
126
+
controller.stop(false)
127
+
end
128
+
129
+
it"restarts when Restart is raised into the running controller thread"do
130
+
defcontroller.setup(container)
131
+
container.spawndo |instance|
132
+
instance.ready!
133
+
sleep
134
+
end
135
+
end
136
+
137
+
# Run the controller in a thread so we can deliver `Restart` via `Thread#raise`, which is the in-process (cross-thread) analog of sending `SIGHUP` to a process running a controller. `Child#restart!` uses exactly this mechanism.
138
+
thread=Thread.newdo
139
+
Thread.current.report_on_exception=false
140
+
controller.run
141
+
end
142
+
143
+
# Wait until the controller is running:
144
+
10.timesdo
145
+
breakifcontroller.running?
146
+
sleep0.1
147
+
end
148
+
expect(controller).tobe(:running?)
149
+
150
+
first=controller.container
151
+
152
+
thread.raise(Async::Container::Restart)
153
+
154
+
# Wait until the container has been replaced by the restart:
0 commit comments