-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nWacky ,
Тесты не компилируются.
Пересмотрел некоторые вещи еще раз, сервер (actix_web::HttpServer) выключается graceful только при SIGTERM |
Обсудили, решили сделать следующее: ОписаниеКласс ДеталиАдреса подписавшихся хранятся в Чем меньше число приоритета, тем выше приоритет. 0 - самый высокий приоритет. При получении
После того, как создали эту большую future, Например, Для выполнения futures внутри |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тыц. Но, там не совсем все верно, требуется обсудить повторно.
Есть еще одна проблема: логгер в actix web паникует пока выключается actix_web:
Из-за этого вся система actix зависает, невозможно никаким образом что-либо сделать (в том числе и таймаут зависает в текущем или если его вынести в другой actor). |
Обсудили, решили следующее:
|
Если использовать контекст Я не нашел как сделать из |
@nWacky why? |
I tried using it this way:
For now the state is being changed with EDIT: I tried using |
Обсудили, решили следующее:
|
# Conflicts: # src/api/client/server.rs # src/main.rs # src/turn/service.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is too "dirty". A lot of unnecessary changes were introduced (like Send
bounds, unremoved CloseRoom
message, etc). The documentation was mostly missing.
You should put much more effort to the quality of your implementations in future.
At the moment, I've refactored it. Consider the changes carefully, and do the final testing on the implementation.
FCM:
Implement graceful shutdown (#30, #29)
- impl GracefulShutdown service which listens to OS signals and shutdowns each component gracefully
- impl graceful shutdown for Room and HTTP server
- add [shutdown] config section
Additionally:
- provide explicit states for Room
Be careful with merging and specifying FCM in the Github form:
- First line of FCM should go as a title.
- Everything other as a body.
Do not forget to remove WIP:
prefix.
Cargo.toml
Outdated
actix = "0.7" | ||
actix-web = "0.7" | ||
actix = "0.8" | ||
actix-rt = "0.2.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you specify the patch version when all the other deps specify minor version only?
src/conf/shutdown_config.rs
Outdated
|
||
#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] | ||
#[serde(default)] | ||
pub struct ShutdownConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like was said earlier: just Shutdown
is enough here. No sense to specify Configuration
term as you are in conf
module already. You had the similar declarations nearby, don't the difference confuse you?
src/conf/shutdown_config.rs
Outdated
#[serde(default)] | ||
pub struct ShutdownConfiguration { | ||
#[default(5000)] | ||
pub timeout: u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is mandatory.
src/shutdown/mod.rs
Outdated
|
||
use crate::log::prelude::*; | ||
|
||
#[derive(Ord, PartialOrd, PartialEq, Eq, Copy, Clone)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetical order by default should be applied.
src/shutdown/mod.rs
Outdated
info!("Exit signal received, exiting"); | ||
|
||
if self.recipients.is_empty() { | ||
error!("GracefulShutdown: No subscribers registered"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, why is this an error? It's a totally normal situation.
src/signalling/participants.rs
Outdated
pub fn drop_connections( | ||
&mut self, | ||
ctx: &mut Context<Room>, | ||
) -> impl Future<Item = (), Error = ()> { | ||
) -> Box<impl Future<Item = (), Error = ()> + Send> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either you use impl Future
, or Box<dyn Future>
.
Box<impl Future>
is unlikely what you want.
src/signalling/room.rs
Outdated
#[derive(Message)] | ||
#[rtype(result = "()")] | ||
#[allow(clippy::module_name_repetitions)] | ||
struct RoomSetStopped {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this Message
for? I didn't found any usages of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was used to set Room
's state to Stopped
back when I was returning futures from ShutdownGracefully
because I couldn't modify self from these futures
There is no use for it now
API HTTP server: {}", | ||
e | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Напрягает толстый main. main, в моем представлении, должен просто собирать контекст. Предлагаю инжектить
graceful_shutdown в new всех интересующих нас компонентов и там уже подписываться.
Тут, теоретическим минусом может быть то, что тогда Room::new будет рурму не только собирать, но и стартовать. Но я не думаю что это будет проблемой.
Если не так, то тогда хотя бы какой-нибудь helper запилю, дабы кода в main было чуть меньше.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexlapa let's refactor it later. Things will be much simple with async
/.await
usage. And the subscribing itself will be moved to Actor
initialization for each kind of long-living thing. But for now just left it as is...
# Conflicts: # Cargo.lock # config.toml # src/api/client/server.rs # src/conf/mod.rs
Graceful Shutdown
Resolves #29
Synopsis
Add shutdown all connections and remove all data from db when a program receives SIGHUP, SIGINT, SIGTERM, SIGQUIT.
Checklist
WIP:
prefixk::
labels appliedWIP:
prefix is removed