Comments (6)
Hey,
if you want to use your own lifecycle instead of serve
, there is normal API with start().await
and shutdown().await
, so you can handle signals yourself and have other lifecycle you need.
serve
is just a wrapping method created for convenience/examples.
from slack-morphism-rust.
Oh I just wanted to run it in main, and hit Ctrl-C
to exit, nothing fancy. So just using serve
for convenience.
Thing is, I also run a client/listener for a discord bot in the same app, so at least one of those 2 await
s nees to go into their own tokio task.
Sending a Ctrl-C
while discord serenity's client is inisde a task is handled gracefuly, thankfully, so I just do that - but Morphism - not so much.
from slack-morphism-rust.
Yeah, as I suspected you have other stuff to run and await :)
You need to use
slack.start().await
<- this will be returned as soon as it is readydiscord_client.start().await
// Not sure if they're blocking thread or not- your own handler for signals (you can use ctrlc yourself if you want)
slack.shutdown().await
<- to disconnect from Slack server for Socket Mode- other cleanups (discord?)
from slack-morphism-rust.
The nature of an error is coming from the ctrlc implementation:
https://detegr.github.io/doc/ctrlc/fn.set_handler.html#
Should only be called once, typically at the start of your program
I suspect someone else already set it. I don't have a windows machine to debug it more, so if you are able to find a better implementation for windows, let me know :)
from slack-morphism-rust.
Ahh, thank you, your example actually makes the api a lot clearer. I (wasn't awake enough and) didn't read hard enough into it, so I had assumed I would've needed to setup events to send signals or some such, but it's just two split calls - appreciate it!
My qualms have been resolved (Thanks!), so I'll let you handle closing the issue in the hopes that a good ctrl-c lib that fixes this comes along ?
from slack-morphism-rust.
Well, if it works for you, then I'll close this issue, since as I mentioned, serve
is just using ctrlc for Windows (if you look at the source code, it just 3-4 lines of code).
In real life application start/shutdown is a way to go.
from slack-morphism-rust.
Related Issues (20)
- De-serializing views requires optional parameters to be present HOT 6
- How to use SlackClientHttpConnector for SlackClient? HOT 1
- Missing element types for actions block HOT 5
- Missing `state` field for block actions payload HOT 2
- How can I update my activity? ? HOT 4
- Add `member_joined_channel` event HOT 5
- Proxy support for Socket Mode (WS) HOT 1
- Missing event types: `block_suggestion` UrlEncoded payload POST from slack and a the required response for populating a dropdown HOT 2
- Missing types in Enum SlackMessageEventType HOT 3
- Windows feature flag HOT 2
- Support for replace_original? HOT 3
- Error on reaction_added events HOT 2
- Potential segfault in the time crate HOT 2
- `SlackAppMentionEvent` doesn't include `edited` field HOT 1
- Re-export `http::status::StatusCode` HOT 3
- Message change event parsing is broken HOT 3
- Possibly missing field "user" in message_changed event HOT 2
- Upload binary files HOT 5
- Proposal: Organising type names and re-exports for v2 HOT 4
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 slack-morphism-rust.