Skip to content

Commit

Permalink
revert oneshot logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrison Ford committed Jan 10, 2024
1 parent 2ef435c commit e7ecb87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ struct RunOptions {
#[arg(short, long)]
oneshot: bool,

#[arg(short, long)]
#[arg(long)]
no_launch: bool,

#[arg(long)]
no_exit: bool,

#[arg(short, long)]
team_test: bool,
}
Expand All @@ -66,6 +69,7 @@ async fn run(options: RunOptions) -> Result<i32> {
team_test,
creator_id,
creator_type,
no_exit
} = options;
let mut script = File::open(script)?;
let mut str = String::default();
Expand All @@ -82,6 +86,7 @@ async fn run(options: RunOptions) -> Result<i32> {
team_test,
creator_id,
creator_type,
no_exit
};

let (exit_sender, exit_receiver) = async_channel::unbounded::<()>();
Expand Down
19 changes: 12 additions & 7 deletions src/place_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ use roblox_install::RobloxStudio;
use crate::message_receiver::{self, Message, RobloxMessage};

/// A wrapper for `process::Child` that force-kills the process on drop.
struct KillOnDrop(process::Child);
struct KillOnDrop(process::Child, bool);

impl Drop for KillOnDrop {
fn drop(&mut self) {
if self.1 {
return;
}
let _ignored = self.0.kill();
}
}
Expand All @@ -30,6 +33,7 @@ pub struct PlaceRunner {
pub no_launch: bool,
pub oneshot: bool,
pub team_test: bool,
pub no_exit: bool,
}

impl PlaceRunner {
Expand Down Expand Up @@ -125,6 +129,7 @@ impl PlaceRunner {
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()?,
self.no_exit,
))
};

Expand All @@ -134,24 +139,24 @@ impl PlaceRunner {
match msg {
Message::Start { server } => {
info!("studio server {server:} started");
//
//
api_svc
.queue_event(
server.clone(),
message_receiver::RobloxEvent::RunScript {
script: self.script.clone(),
oneshot: self.oneshot && !self.no_launch
oneshot: self.oneshot
},
)
.await;
// By default, if "oneshot" and "no_launch" mode is specified,
// we don't have control over the Studio executable's lifecycle,
// so we'll send a "Deregister" message to Studio so that this application
// can exit cleanly, allowing you to re-run it again in a sort-of-"watch mode".
if self.oneshot && self.no_launch {
api_svc
.queue_event(server.clone(), message_receiver::RobloxEvent::Deregister).await;
}
// if self.oneshot && self.no_launch {
// api_svc
// .queue_event(server.clone(), message_receiver::RobloxEvent::Deregister).await;
// }
}
Message::Stop { server } => {
info!("studio server {server:} stopped");
Expand Down

0 comments on commit e7ecb87

Please sign in to comment.