Adding waitForState API to wait for server startup

Signed-off-by: Tsuyoshi Ozawa <ozawa.tsuyoshi@gmail.com>