feat: add tokio runtime and make adync gpio interups on seperate thread
This commit is contained in:
parent
19862ecf70
commit
716153b1b6
4 changed files with 19 additions and 12 deletions
14
Cargo.toml
14
Cargo.toml
|
|
@ -5,10 +5,10 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
tokio = { version = "1.36", features = ["full"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
rppal = "0.22"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tracing-appender = "0.2"
|
||||
serenity = { version = "0.12", features = ["standard_framework"] }
|
||||
tokio = { version = "1.45.1", features = ["full"] }
|
||||
tracing = "0.1.41"
|
||||
tracing-subscriber = "0.3.19"
|
||||
rppal = "0.22.1"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
tracing-appender = "0.2.3"
|
||||
serenity = { version = "0.12.4", features = ["standard_framework"] }
|
||||
|
|
|
|||
12
deploy.sh
12
deploy.sh
|
|
@ -38,13 +38,17 @@ WantedBy=multi-user.target
|
|||
EOL
|
||||
|
||||
echo "Copying to Raspberry Pi..."
|
||||
# Copy files
|
||||
scp target/aarch64-unknown-linux-gnu/release/noisebell noisebridge@noisebell.local:~/
|
||||
scp noisebell.service noisebridge@noisebell.local:~/
|
||||
# Debug remote directory status
|
||||
ssh noisebridge@noisebell.local "pwd && ls -la ~/ && echo 'Directory permissions:' && stat -c '%A %a %n' ~/"
|
||||
# Remove existing files
|
||||
ssh noisebridge@noisebell.local "rm -f /home/noisebridge/noisebell /home/noisebridge/noisebell.service"
|
||||
# Copy files with absolute paths
|
||||
scp -v target/aarch64-unknown-linux-gnu/release/noisebell noisebridge@noisebell.local:/home/noisebridge/noisebell
|
||||
scp -v noisebell.service noisebridge@noisebell.local:/home/noisebridge/noisebell.service
|
||||
|
||||
echo "Setting up service..."
|
||||
# Deploy service
|
||||
ssh noisebridge@noisebell.local "sudo cp ~/noisebell.service /etc/systemd/system/ && \
|
||||
ssh noisebridge@noisebell.local "sudo cp /home/noisebridge/noisebell.service /etc/systemd/system/ && \
|
||||
sudo systemctl daemon-reload && \
|
||||
sudo systemctl enable noisebell && \
|
||||
sudo systemctl restart noisebell"
|
||||
|
|
|
|||
0
logs/noisebell.2025-06-11.log
Normal file
0
logs/noisebell.2025-06-11.log
Normal file
|
|
@ -27,11 +27,14 @@ async fn main() -> Result<()> {
|
|||
Duration::from_secs(DEFAULT_DEBOUNCE_DELAY_SECS)
|
||||
)?;
|
||||
|
||||
// Get a handle to the current runtime
|
||||
let runtime = tokio::runtime::Handle::current();
|
||||
|
||||
// Set up the callback for state changes
|
||||
let callback = move |event: gpio::CircuitEvent| {
|
||||
info!("Circuit state changed to: {:?}", event);
|
||||
let discord_client = discord_client.clone();
|
||||
tokio::spawn(async move {
|
||||
runtime.spawn(async move {
|
||||
let space_event = match event {
|
||||
gpio::CircuitEvent::Open => discord::SpaceEvent::Open,
|
||||
gpio::CircuitEvent::Closed => discord::SpaceEvent::Closed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue