| 1885 | int mainEntryClickHouseLocal(int argc, char ** argv); |
| 1886 | |
| 1887 | int mainEntryClickHouseLocal(int argc, char ** argv) |
| 1888 | { |
| 1889 | DB::MainThreadStatus::getInstance(); |
| 1890 | |
| 1891 | /// Join global-pool threads before the statics they may have accessed are destroyed. |
| 1892 | /// That way, accesses happen-before destruction. |
| 1893 | SCOPE_EXIT_SAFE({ |
| 1894 | DB::StaticThreadPool::shutdownAll(); |
| 1895 | GlobalThreadPool::shutdown(); |
| 1896 | }); |
| 1897 | |
| 1898 | try |
| 1899 | { |
| 1900 | DB::LocalServer app; |
| 1901 | app.init(argc, argv); |
| 1902 | return app.run(); |
| 1903 | } |
| 1904 | catch (DB::Exception & e) |
| 1905 | { |
| 1906 | std::cerr << DB::getExceptionMessageForLogging(e, false) << std::endl; |
| 1907 | auto code = DB::getCurrentExceptionCode(); |
| 1908 | return static_cast<UInt8>(code) ? code : 1; |
| 1909 | } |
| 1910 | catch (const boost::program_options::error & e) |
| 1911 | { |
| 1912 | std::cerr << "Bad arguments: " << e.what() << std::endl; |
| 1913 | return DB::ErrorCodes::BAD_ARGUMENTS; |
| 1914 | } |
| 1915 | catch (...) |
| 1916 | { |
| 1917 | std::cerr << DB::getCurrentExceptionMessage(true) << '\n'; |
| 1918 | auto code = DB::getCurrentExceptionCode(); |
| 1919 | return static_cast<UInt8>(code) ? code : 1; |
| 1920 | } |
| 1921 | } |
no test coverage detected