diff options
| -rw-r--r-- | common.mk | 3 | ||||
| -rw-r--r-- | debian/control | 2 | ||||
| -rw-r--r-- | https.cpp | 1 | ||||
| -rw-r--r-- | plugins/cgi/cgi.cpp | 1 | ||||
| -rw-r--r-- | plugins/static-files/static-files.cpp | 2 | ||||
| -rw-r--r-- | plugins/statistics/statistics.cpp | 1 | ||||
| -rw-r--r-- | plugins/webbox/webbox.cpp | 4 | ||||
| -rw-r--r-- | plugins/weblog/weblog.cpp | 2 | ||||
| -rw-r--r-- | response.cpp | 1 | ||||
| -rw-r--r-- | tests/test-webserver.cpp | 25 | 
10 files changed, 41 insertions, 1 deletions
| @@ -97,6 +97,9 @@ LIBS+= \  CXXTYPE=g++  endif +CXXFLAGS+=$(shell pkg-config --cflags fmt) +LIBS+=$(shell pkg-config --libs fmt) +  SRC_ROOT=$(shell echo $(MAKEFILE_LIST) | tr " " "\n" | grep common.mk | sed -e 's/\([^ ]*\)common.mk/\1/g')  VERSION=$(shell dpkg-parsechangelog --show-field Version --file $(SRC_ROOT)/debian/changelog)  CXXFLAGS+=-DVERSION=\"$(VERSION)\" diff --git a/debian/control b/debian/control index a48c5df..e0de083 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: webserver  Section: httpd  Priority: optional  Maintainer: Roland Reichwein <mail@reichwein.it> -Build-Depends: debhelper (>= 12), libssl-dev, libboost-all-dev | libboost1.71-all-dev, clang | g++, llvm | g++, lld | g++, uglifyjs, python3-pkg-resources, htmlmin, cleancss, libreichwein-dev, gcovr +Build-Depends: debhelper (>= 12), libssl-dev, libboost-all-dev | libboost1.71-all-dev, clang | g++, llvm | g++, lld | g++, uglifyjs, python3-pkg-resources, htmlmin, cleancss, libreichwein-dev, gcovr, libfmt-dev  Standards-Version: 4.5.0  Homepage: http://www.reichwein.it/webserver/ @@ -40,6 +40,7 @@ namespace http = beast::http;           // from <boost/beast/http.hpp>  namespace net = boost::asio;            // from <boost/asio.hpp>  namespace ssl = boost::asio::ssl;       // from <boost/asio/ssl.hpp>  using tcp = boost::asio::ip::tcp;       // from <boost/asio/ip/tcp.hpp> +using namespace Reichwein;  namespace { diff --git a/plugins/cgi/cgi.cpp b/plugins/cgi/cgi.cpp index 4e4f6c7..23c9bc4 100644 --- a/plugins/cgi/cgi.cpp +++ b/plugins/cgi/cgi.cpp @@ -16,6 +16,7 @@  using namespace std::string_literals;  namespace bp = boost::process;  namespace fs = std::filesystem; +using namespace Reichwein::Mime;  namespace { diff --git a/plugins/static-files/static-files.cpp b/plugins/static-files/static-files.cpp index e889bc5..4dd8499 100644 --- a/plugins/static-files/static-files.cpp +++ b/plugins/static-files/static-files.cpp @@ -12,6 +12,8 @@  using namespace std::string_literals;  namespace fs = std::filesystem; +using namespace Reichwein::Mime; +using namespace Reichwein::URL;  namespace { diff --git a/plugins/statistics/statistics.cpp b/plugins/statistics/statistics.cpp index 54450a8..959fd33 100644 --- a/plugins/statistics/statistics.cpp +++ b/plugins/statistics/statistics.cpp @@ -18,6 +18,7 @@  using namespace std::string_literals;  namespace bp = boost::process;  namespace fs = std::filesystem; +using namespace Reichwein;  namespace { diff --git a/plugins/webbox/webbox.cpp b/plugins/webbox/webbox.cpp index 90975b5..df7e946 100644 --- a/plugins/webbox/webbox.cpp +++ b/plugins/webbox/webbox.cpp @@ -27,6 +27,10 @@  using namespace std::string_literals;  namespace fs = std::filesystem;  namespace pt = boost::property_tree; +using namespace Reichwein::Mime; +using namespace Reichwein::Stringutil; +using namespace Reichwein::URL; +using namespace Reichwein;  namespace { diff --git a/plugins/weblog/weblog.cpp b/plugins/weblog/weblog.cpp index 8be5b40..1aea2f4 100644 --- a/plugins/weblog/weblog.cpp +++ b/plugins/weblog/weblog.cpp @@ -18,6 +18,8 @@  using namespace std::string_literals;  namespace fs = std::filesystem;  namespace pt = boost::property_tree; +using namespace Reichwein::Mime; +using namespace Reichwein::Stringutil;  namespace { diff --git a/response.cpp b/response.cpp index 4f535df..92390cd 100644 --- a/response.cpp +++ b/response.cpp @@ -15,6 +15,7 @@  #include <unordered_map>  using namespace std::placeholders; +using namespace Reichwein::Mime;  namespace { diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp index 4ac550e..7826a58 100644 --- a/tests/test-webserver.cpp +++ b/tests/test-webserver.cpp @@ -15,6 +15,8 @@  #include <boost/property_tree/ptree.hpp>  #include <boost/property_tree/xml_parser.hpp> +#include <fmt/core.h> +  #include <chrono>  #include <filesystem>  #include <iostream> @@ -33,6 +35,7 @@  using namespace std::string_literals;  namespace fs = std::filesystem;  namespace pt = boost::property_tree; +using namespace Reichwein;  class WebserverProcess  { @@ -118,6 +121,28 @@ public:    m_pid = 0;   } + bool isRunning() + { +  if (m_pid == 0) +   return false; + +  fs::path pid_file{fmt::format("/proc/{}/stat", m_pid)}; +  if (!fs::exists(pid_file)) +   return false; + +  std::string s{File::getFile(pid_file)}; + +  auto pos0{s.find(' ', 0)}; +  pos0 = s.find(' ', pos0 + 1); +  pos0++; + +  auto pos1{s.find(' ', pos0 + 1)}; + +  std::string state{s.substr(pos0, pos1 - pos0)}; + +  return state == "R" || state == "S"; + } +  private:   pid_t m_pid;  }; | 
