我使用带有flapdoodle的Mongo嵌入式版本的Spring Boot。
问题在于,每当我关闭应用程序时,我都会看到一些警告和消息,告诉Mongo无法关闭"优雅"。
这是输出:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.M1)
06-15-2017 23:08:11.860 |- DEBUG in ApplicationKt:51 [main] - Running with Spring Boot v2.0.0.M1, Spring v5.0.0.RC1
06-15-2017 23:08:11.862 |- INFO in ApplicationKt:699 [main] - The following profiles are active: default
06-15-2017 23:08:15.524 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - [mongod output]note: noprealloc may hurt performance in many applications[mongod output]
06-15-2017 23:08:15.528 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:15.528-0400 I CONTROL [initandlisten] MongoDB starting : pid=3283 port=44881 dbpath=/tmp/embedmongo-db-22696ae1-2b81-4c52-b415-c00fb232d37f 64-bit host=uplink[mongod output]
06-15-2017 23:08:15.528 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:15.528-0400 I CONTROL [initandlisten] db version v3.2.2[mongod output]
06-15-2017 23:08:15.529 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:15.528-0400 I CONTROL [initandlisten] git version: 6e71d0d568e134c029203593b00a0103e7cdf30b[mongod output]
...
06-15-2017 23:08:21.101 |- INFO in NettyWebServer:73 [main] - Netty started on port(s): 9080
06-15-2017 23:08:21.130 |- INFO in ApplicationKt:57 [main] - Started ApplicationKt in 4.965 seconds (JVM running for 6.423)
06-15-2017 23:08:25.457 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.457-0400 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends[mongod output]
06-15-2017 23:08:25.458 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.457-0400 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture[mongod output]
06-15-2017 23:08:25.461 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I CONTROL [signalProcessingThread] now exiting[mongod output]
06-15-2017 23:08:25.461 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...[mongod output]
06-15-2017 23:08:25.461 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I NETWORK [signalProcessingThread] closing listening socket: 5[mongod output]
06-15-2017 23:08:25.461 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I NETWORK [signalProcessingThread] closing listening socket: 6[mongod output]
06-15-2017 23:08:25.462 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-44881.sock[mongod output]
06-15-2017 23:08:25.462 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog...[mongod output]
06-15-2017 23:08:25.462 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I NETWORK [signalProcessingThread] shutdown: going to close sockets...[mongod output]
06-15-2017 23:08:25.462 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.460-0400 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down[mongod output]
06-15-2017 23:08:25.469 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.461-0400 I NETWORK [conn2] end connection 127.0.0.1:41594 (1 connection now open)[mongod output]
06-15-2017 23:08:25.470 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.461-0400 I NETWORK [conn1] end connection 127.0.0.1:41592 (0 connections now open)[mongod output]
06-15-2017 23:08:25.470 |- WARN in Mongod:103 [Thread-5] - sendShutdown /127.0.0.1:44881
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at de.flapdoodle.embed.mongo.runtime.Mongod.sendShutdown(Mongod.java:87)
at de.flapdoodle.embed.mongo.AbstractMongoProcess.sendStopToMongoInstance(AbstractMongoProcess.java:133)
at de.flapdoodle.embed.mongo.AbstractMongoProcess.stopInternal(AbstractMongoProcess.java:107)
at de.flapdoodle.embed.process.runtime.AbstractProcess.stop(AbstractProcess.java:170)
at de.flapdoodle.embed.process.runtime.AbstractProcess$JobKiller.run(AbstractProcess.java:243)
at java.lang.Thread.run(Thread.java:748)
06-15-2017 23:08:25.571 |- WARN in AbstractMongoProcess:108 [Thread-5] - could not stop mongod with db command, try next
06-15-2017 23:08:25.633 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.633-0400 I STORAGE [signalProcessingThread] shutdown: removing fs lock...[mongod output]
06-15-2017 23:08:25.633 |- INFO in EmbeddedMongoDbConfig:42 [Thread-6] - 2017-06-15T23:08:25.633-0400 I CONTROL [signalProcessingThread] dbexit: rc: 0[mongod output]
Process finished with exit code 130 (interrupted by signal 2: SIGINT)
有没有办法避免这种情况并将其关闭"优雅"?
更新:有时失败......有时候没有。我无法看到(或弄清楚)一种模式。我最初很担心它,因为我认为它可能会留下资源和/或文件"无人值守&#34 ;;但到目前为止,它清理了所有东西 - 即使是那些警告。