Emit log when emulator successfully starts
Closed this issue · 3 comments
Issue To Be Solved
Currently, the flow emulator emits logs only when it transitions to "starting" state or to "error" state.
Transition to "starting" state:
> flow emulator
INFO[0000] ⚙️ Using service account 0xf8d6e0586b0a20c7 serviceAddress=f8d6e0586b0a20c7 serviceHashAlgo=SHA3_256 servicePrivKey=17db68f620ff786e3e5a8b87ba577093caece160f7ac57f5c619d86b973b7628 servicePubKey=a8d2074251eb721254004d758cf71d0bf8300651d25d6ef1991c41448ae02b8a61d232cb53a9d0f0b7adefec25fd267ed7bc09dd1490cb201f38b3b5ba783991 serviceSigAlgo=ECDSA_P256
INFO[0000] 📜 Flow contract FlowServiceAccount=0xf8d6e0586b0a20c7
INFO[0000] 📜 Flow contract FlowToken=0x0ae53cb6e3f42a79
INFO[0000] 📜 Flow contract FungibleToken=0xee82856bf20e2aa6
INFO[0000] 📜 Flow contract FlowFees=0xe5a8b7f23e8b548f
INFO[0000] 📜 Flow contract FlowStorageFees=0xf8d6e0586b0a20c7
INFO[0000] 🌱 Starting gRPC server on port 3569 port=3569
INFO[0000] 🌱 Starting REST API on port 8888 port=8888
INFO[0000] 🌱 Starting admin server on port 8080 port=8080
Transition to "error" state:
> flow emulator
INFO[0000] ⚙️ Using service account 0xf8d6e0586b0a20c7 serviceAddress=f8d6e0586b0a20c7 serviceHashAlgo=SHA3_256 servicePrivKey=17db68f620ff786e3e5a8b87ba577093caece160f7ac57f5c619d86b973b7628 servicePubKey=a8d2074251eb721254004d758cf71d0bf8300651d25d6ef1991c41448ae02b8a61d232cb53a9d0f0b7adefec25fd267ed7bc09dd1490cb201f38b3b5ba783991 serviceSigAlgo=ECDSA_P256
INFO[0000] 📜 Flow contract FlowFees=0xe5a8b7f23e8b548f
INFO[0000] 📜 Flow contract FlowStorageFees=0xf8d6e0586b0a20c7
INFO[0000] 📜 Flow contract FlowServiceAccount=0xf8d6e0586b0a20c7
INFO[0000] 📜 Flow contract FlowToken=0x0ae53cb6e3f42a79
INFO[0000] 📜 Flow contract FungibleToken=0xee82856bf20e2aa6
ERRO[0000] ❗ Failed to startup REST API error="listen tcp :8888: bind: address already in use"
I think it would be good to also emit a log when the emulator started successfully - when it transitions from "starting" to "started" state. This is because currently there is no indication if the emulator indeed started without errors.
Suggest A Solution
Emit "started" info log after all the flow-emulator components were started successfully. This will indicate that no startup errors can occur from now on.
Example output:
INFO[0000] 🌱 Starting gRPC server on port 3569 port=3569
INFO[0000] 🌱 Starting REST API on port 8888 port=8888
INFO[0000] 🌱 Starting admin server on port 8080 port=8080
INFO[0000] ✅ Started gRPC server on port 3569 port=3569
INFO[0000] ✅ Started REST API on port 8888 port=8888
INFO[0000] ✅ Started admin server on port 8080 port=8080
Related code that would need to be modified:
flow-emulator/server/server.go
Lines 189 to 229 in fd49363
Context
The lack of this log, also makes it harder to detect successful startups programmatically. For example, at Flowser, we currently assume that if no error logs are emitted 1s after "started" logs were seen, the emulator started successfully - which is not ideal.
See our issue: onflowser/flowser#33
This needs to be logged at Start
of each Server.
- Do we keep
starting
logs or just logstarted
? - We can move also port listening to start probably. ( if we will keep
starting
message )
@bluesign I believe if we just say starting up (as in general starting up) and then add server started at the end of all services is fine. I believe that would need to change the library we use for that, or we could like you said just announce when each server is started.
Yeah I think without changing the library would be the easiest, services already have logger for error messages.