Skip to content

Commit

Permalink
Addressed review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-dfinity committed Nov 7, 2024
1 parent 98418a3 commit 060b256
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ Allow setting permissions lists in init arguments just like in upgrade arguments
- Module hash: f45db224b40fac516c877e3108dc809d4b22fa42d05ee8dfa5002536a3a3daed
- Bump agent-js to fix error code

### chore: improve `dfx start` messages.

For `dfx start`, show below messages to users to indicate what to do next.
```
Success! The dfx server is running.
You must open a new terminal to continue developing. If you'd prefer to stop, quit with 'Ctrl-C'.
```

# 0.24.2

### feat: Support canister log allowed viewer list
Expand All @@ -32,14 +40,6 @@ The frontend canister sync now tries to batch multiple small content chunks into
And for small amounts of uploaded data the asset sync can now skip chunk creation entirely.
This should lead to significantly faster upload times for frontends with many small files.

### chore!: improve `dfx start` messages.

For `dfx start`, show below messages to users to indicate what to do next.
```
The dfx server is running.
You can start a new terminal to continue developing, or quit with 'Ctrl-C'.
```

## Dependencies

### Motoko
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests-dfx/start.bash
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ teardown() {

@test "start and stop outside project" {
assert_command dfx_start
assert_contains "The dfx server is running in the background."
assert_contains "Success! The dfx server is running in the background."

mkdir subdir
cd subdir || exit 1
Expand Down
4 changes: 2 additions & 2 deletions src/dfx/src/actors/post_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ impl Handler<PocketIcProxyReadySignal> for PostStart {
fn handle(&mut self, _msg: PocketIcProxyReadySignal, _ctx: &mut Self::Context) -> Self::Result {
let logger = &self.config.logger;
if self.config.background {
info!(logger, "The dfx server is running in the background.")
info!(logger, "Success! The dfx server is running in the background.")
} else {
info!(logger, "The dfx server is running.\nYou can start a new terminal to continue developing, or quit with 'Ctrl-C'.");
info!(logger, "Success! The dfx server is running.\nYou must open a new terminal to continue developing. If you'd prefer to stop, quit with 'Ctrl-C'.");
}
}
}
13 changes: 7 additions & 6 deletions src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub struct StartOpts {
#[arg(long)]
background: bool,

/// Indicates if the actual dfx process is running in the background.
#[arg(long, env = "DFX_RUNNING_IN_BACKGROUND", hide = true)]
running_in_background: bool,

/// Cleans the state of the current project.
#[arg(long)]
clean: bool,
Expand Down Expand Up @@ -139,6 +143,7 @@ pub fn exec(
StartOpts {
host,
background,
running_in_background,
clean,
force,
bitcoin_node,
Expand Down Expand Up @@ -265,10 +270,6 @@ pub fn exec(
}
local_server_descriptor.describe(env.get_logger());

// Get the original background flag set by the user from the command arguments.
// Get it from the environment variable as the `--background` flag will be ignored by the send_background() method.
let original_background = std::env::var("original_background").is_ok();

write_pid(&pid_file_path);
fs::write(&webserver_port_path, address_and_port.port().to_string())?;

Expand Down Expand Up @@ -419,7 +420,7 @@ pub fn exec(
pocketic_proxy_port_file_path,
)?;

let post_start = start_post_start_actor(env, original_background, Some(proxy))?;
let post_start = start_post_start_actor(env, running_in_background, Some(proxy))?;

Ok::<_, Error>(post_start)
})?;
Expand Down Expand Up @@ -583,7 +584,7 @@ fn send_background() -> DfxResult<()> {
.filter(|a| !a.eq("--background"))
.filter(|a| !a.eq("--clean")),
)
.env("original_background", "true"); // Set the `original_background` environment variable which will be used by the second start.
.env("DFX_RUNNING_IN_BACKGROUND", "true"); // Set the `DFX_RUNNING_IN_BACKGROUND` environment variable which will be used by the second start.

cmd.spawn().context("Failed to spawn child process.")?;
Ok(())
Expand Down

0 comments on commit 060b256

Please sign in to comment.