Comments (10)
@XX currently this way:
let default_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
actix::System::with_current(|sys| sys.stop_with_code(1));
default_hook(info);
}));
from actix-net.
@mikhailOK How do you emulate the stop on panic with panic hook?
from actix-net.
I dug into this a little bit. It seems that actix-server
code still assumes that a worker can crash (i.e. uncaught panic) and it has a recovery mechanism in place; whereas with the newer tokio that is not really possible.
See for example here:
actix-net/actix-server/src/builder.rs
Lines 410 to 438 in 235a76d
and here:
actix-net/actix-server/src/accept.rs
Lines 419 to 431 in 235a76d
tokio
do not seem to want to change the current behaviour (mandatory catching of panics within tokio
) so we should consider a refactor to reflect that.
from actix-net.
use panic = "abort"
if you want to exit on panic. tokio::spawn
catch panic the same way as std::thread::spawn
actix-server can be used stand alone and you are free to make worker panic and restart. So worker restart feature is here to stay and remove it is not accepted.
from actix-net.
Seems like #255 removed the stop_on_panic
method from System
.
panic = "abort"
is not always usable because it does not run destructors.
std::thread::spawn
returns a JoinHandle
which allows the code to handle the panic.
Please consider a feature to handle panic behavior.
from actix-net.
Sorry that's outside the scope of actix-server.
You can add your own panic handle by using std::panic
module or use tokio::spawn
which give you a joinhandle.
from actix-net.
Would panic handling functionality make sense for Actor
then, considering Actor::start
swallows the JoinHandle
?
(This is outside of actix-rt
, but originally stop_on_panic
was here)
from actix-net.
Would panic handling functionality make sense for
Actor
then, consideringActor::start
swallows theJoinHandle
?
(This is outside ofactix-rt
, but originallystop_on_panic
was here)
actix-rt
and actix-server
are different crates. And I was mostly explain how you can make actix-server
worker panic and cause restart.
I did not make the change to stop_on_panic
but since it's removed it would have not effect for sure.
I can re-open the issue if you want it back or feel free to make new issue for talking about that.
from actix-net.
@mikhailOK I edited the title of issue and re-opened. Hope you don't mind as we need it back to implement actual panic stop.
from actix-net.
I walked into the exact problem, and when I ported the deleted snippet in #255 to actix 0.12.0 (here), it worked. Not sure why stop_on_panic
is removed.
I also tested this idea on actix-web 4.0.0-beta.8. The program didn't terminate, but new service workers are constructed to accept new connections. I believe this is the expected behavior.
from actix-net.
Related Issues (20)
- Make actix-rt (and actix itself) work with tokio console HOT 1
- error: linking with `cc` failed: exit status: 1 (libactix_server: error adding symbols: bad value) HOT 1
- `actix_rt::main` is not compatible with tokio `block_on` HOT 1
- Make System::with_tokio_rt take a `FnOnce`
- actix-codec: Support Half streams HOT 2
- local-waker sub-crate does not include license files HOT 1
- Run server again after stopping it by ServerHandle::stop() HOT 2
- Feature Request: add new feature `rustls-native-certs` HOT 4
- impl Transform for Option HOT 1
- how to close connection immediately? HOT 1
- Support Tokio 0.2.x HOT 1
- Syn 2 upgrade
- publish actix-codec 0.5.1 to creates.io HOT 1
- actix-tls 3.0.4 was never released HOT 4
- SECURITY: please cut new release (actix-tls) HOT 4
- Crates.io page is outdated. HOT 2
- Please update the ring crate to 17.x HOT 1
- actix-tls 3.1.1 introduces rustls dependency forcibly HOT 3
- actix-macros don't support build on alpine(aarch64) HOT 1
- Release new version of actix codec HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actix-net.