diff --git a/CMakeLists.txt b/CMakeLists.txt index f7974046c..3cde7e75d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,10 @@ target_link_libraries(urm PUBLIC ${SERVER_LIBS}) # Install bin install(TARGETS urm RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -# Install service pkg_check_modules(PC_SYSTEMD QUIET systemd) if(PC_SYSTEMD_FOUND) + # Install slice file + install(FILES ${CMAKE_SOURCE_DIR}/focused.slice DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE) + # Install service install(FILES ${CMAKE_SOURCE_DIR}/urm.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system/) endif() diff --git a/focused.slice b/focused.slice new file mode 100644 index 000000000..ba59a2a39 --- /dev/null +++ b/focused.slice @@ -0,0 +1,9 @@ +[Unit] +Description=Custom Cgroup for URM + +[Slice] +CPUQuota=100% +MemoryMax=500M +CPUWeight=100 # max weight for CPU +IOWeight=100 # max weight for IO +TasksMax=100 # maximum number of concurrent tasks (processes + threads) allowed in that cgroup diff --git a/urm.service b/urm.service index 5ee70c0ce..a451075ab 100644 --- a/urm.service +++ b/urm.service @@ -5,6 +5,8 @@ Description=URM Service Restart=on-failure ExecStart=/usr/bin/urm TimeoutStopSec=2 +Slice=focused.slice +Delegate=yes [Install] WantedBy=multi-user.target