Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Add flag for starting ganache in detached mode #1001

@fvictorio

Description

@fvictorio

Expected Behavior

I would like to run ganache-cli in such a way that it runs in the background but the command returns when the startup is done. Right now to do that you have to do something like:

ganache-cli &
sleep 5
# interact with localhost:8545 somehow

because ganache isn't immediately ready. With a proper flag, this would become:

ganache-cli --detach
# interact with localhost:8545 somehow

Current Behavior

As explained in the previous section, right now you have to start the process in the background (using &) and then you have to wait a while (how much changes a lot from machine to machine) until it's ready.

Possible Solution

A flag like --detach should do the trick. In docker, this flag has the -d shortcut, but that's already reserved in ganache. Besides, it's likely that most people won't need this, so having just a long flag should be OK.

I'm not really sure about detach though, since it might imply "it will continue to work if the terminal is closed", which might not be the case.

Context

Having something like this would be specially useful for scripts and CIs. I've seen a lot of scripts and CI configurations that start ganache in the background and then sleep for 3-5 seconds.

Something to take into account is that the user will probably want to have the PID of the process. This could be the only thing that is printed, so you can use it like this:

PID=`ganache-cli --detach`
# do some stuff
kill $PID

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions