From: Kaleb S. KEITHLEY Date: Mon, 23 Dec 2019 17:15:34 +0000 (-0500) Subject: rgw: build radosgw daemon as a shared lib + small executable X-Git-Tag: v15.1.0~308^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f528f173e489437292917fccac2025becd8fce21;p=ceph.git rgw: build radosgw daemon as a shared lib + small executable Majority of radosgw is contained in libradosgw.so. (/usr)/bin/radosgw is now a few lines that calls radosgw_Main() in libradosgw.so. The "zipper" work to modularize storage back-ends that will require linking to the shared library to resolve the methods that they reference. Putting the bulk of the implementation in a shared lib also allows for unit testing to link with the shared lib for testing. radosgw_Main() is the C++ implementation. For C linkage, radosgw_main() is provided. Signed-off-by: Kaleb S. KEITHLEY --- diff --git a/ceph.spec.in b/ceph.spec.in index eda6893b456..2eaca3e2423 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1846,12 +1846,14 @@ fi %{_bindir}/radosgw-token %{_bindir}/radosgw-es %{_bindir}/radosgw-object-expirer +%{_libdir}/libradosgw.so* %{_mandir}/man8/radosgw.8* %dir %{_localstatedir}/lib/ceph/radosgw %{_unitdir}/ceph-radosgw@.service %{_unitdir}/ceph-radosgw.target %post radosgw +/sbin/ldconfig %if 0%{?suse_version} if [ $1 -eq 1 ] ; then /usr/bin/systemctl preset ceph-radosgw@\*.service ceph-radosgw.target >/dev/null 2>&1 || : @@ -1873,6 +1875,7 @@ fi %endif %postun radosgw +/sbin/ldconfig %if 0%{?suse_version} DISABLE_RESTART_ON_UPDATE="yes" %service_del_postun ceph-radosgw@\*.service ceph-radosgw.target diff --git a/debian/radosgw.install b/debian/radosgw.install index 329ea0e480f..b6024ced082 100644 --- a/debian/radosgw.install +++ b/debian/radosgw.install @@ -1,4 +1,5 @@ lib/systemd/system/ceph-radosgw* +lib/*/libradosgw.so* usr/bin/radosgw usr/bin/radosgw-es usr/bin/radosgw-object-expirer diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index d36d57adad6..bb2113ab04a 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -266,21 +266,34 @@ if(WITH_RADOSGW_BEAST_FRONTEND) rgw_dmclock_async_scheduler.cc) endif() -add_library(radosgw_a STATIC ${radosgw_srcs} +add_library(radosgw SHARED ${radosgw_srcs} ${rgw_a_srcs} rgw_main.cc $) -add_library(rgw_schedulers STATIC ${rgw_schedulers_srcs}) -target_link_libraries(rgw_schedulers - PUBLIC dmclock::dmclock) -target_link_libraries(radosgw_a + +add_dependencies(radosgw civetweb_h) + +target_compile_definitions(radosgw PUBLIC "-DCLS_CLIENT_HIDE_IOCTX") +target_include_directories(radosgw PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src") +target_include_directories(radosgw SYSTEM PUBLIC "../rapidjson/include") + +target_link_libraries(radosgw PRIVATE ${rgw_libs} rgw_schedulers - PUBLIC dmclock::dmclock) + PUBLIC dmclock::dmclock +) if(WITH_RADOSGW_BEAST_FRONTEND AND WITH_RADOSGW_BEAST_OPENSSL) +target_link_libraries(radosgw # used by rgw_asio_frontend.cc - target_link_libraries(radosgw_a PRIVATE OpenSSL::SSL) + PRIVATE OpenSSL::SSL) endif() +set_target_properties(radosgw PROPERTIES OUTPUT_NAME radosgw VERSION 2.0.0 + SOVERSION 2) +install(TARGETS radosgw DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +add_library(rgw_schedulers STATIC ${rgw_schedulers_srcs}) +target_link_libraries(rgw_schedulers + PUBLIC dmclock::dmclock) -add_executable(radosgw rgw_main.cc) -target_link_libraries(radosgw radosgw_a librados +add_executable(radosgwd radosgw.cc) +target_link_libraries(radosgwd radosgw librados cls_rgw_client cls_otp_client cls_lock_client cls_refcount_client cls_log_client cls_timeindex_client cls_version_client cls_user_client @@ -288,7 +301,8 @@ target_link_libraries(radosgw radosgw_a librados ${FCGI_LIBRARY} ${LIB_RESOLV} ${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${BLKID_LIBRARIES} ${ALLOC_LIBS}) -install(TARGETS radosgw DESTINATION bin) +set_target_properties(radosgwd PROPERTIES OUTPUT_NAME radosgw) +install(TARGETS radosgwd DESTINATION bin) set(radosgw_admin_srcs rgw_admin.cc diff --git a/src/rgw/radosgw.cc b/src/rgw/radosgw.cc new file mode 100644 index 00000000000..df9e935ed89 --- /dev/null +++ b/src/rgw/radosgw.cc @@ -0,0 +1,13 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp +// + +extern int radosgw_Main(int, const char **); + +/* + * start up the RADOS connection and then handle HTTP messages as they come in + */ +int main(int argc, char **argv) +{ + return radosgw_Main(argc, const_cast(argv)); +} diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index e348cf7b6cc..057ba88af3e 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -171,7 +171,7 @@ static RGWRESTMgr *rest_filter(RGWRados *store, int dialect, RGWRESTMgr *orig) /* * start up the RADOS connection and then handle HTTP messages as they come in */ -int main(int argc, const char **argv) +int radosgw_Main(int argc, const char **argv) { // dout() messages will be sent to stderr, but FCGX wants messages on stdout // Redirect stderr to stdout. @@ -627,3 +627,13 @@ int main(int argc, const char **argv) return 0; } + +extern "C" { + +int radosgw_main(int argc, const char** argv) +{ + return radosgw_Main(argc, argv); +} + +} /* extern "C" */ +