Integrated config less startup with only given CCServer and token #14

Fixed time drift issues on dashboard by sending server time to dashboard and use this for comparisson
This commit is contained in:
BenDroid 2018-01-12 23:11:00 +01:00
parent ede0149552
commit bdb0bb9926
6 changed files with 65 additions and 31 deletions

View file

@ -41,6 +41,8 @@
#include "Summary.h"
#include "workers/Workers.h"
#include "cc/CCClient.h"
#include "net/Url.h"
#ifdef HAVE_SYSLOG_H
# include "log/SysLog.h"
@ -157,6 +159,10 @@ int App::start()
uv_async_init(uv_default_loop(), &m_async, App::onCommandReceived);
m_ccclient = new CCClient(m_options, &m_async);
if (! m_options->pools().front()->isValid()) {
LOG_WARN("No pool URL supplied, but CC server configured. Trying.");
}
} else {
LOG_WARN("Please configure CC-Url and restart. CC feature is now deactivated.");
}
@ -164,7 +170,9 @@ int App::start()
Workers::start(m_options->affinity(), m_options->priority());
m_network->connect();
if (m_options->pools().front()->isValid()) {
m_network->connect();
}
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
uv_loop_close(uv_default_loop());

View file

@ -35,6 +35,10 @@ void App::background()
Cpu::setAffinity(-1, m_options->affinity());
}
Log::i()->text(Options::i()->colors() ? "\x1B[01;31m\nBackground mode is not supported by %s on *nix Systems. Please use screen/tmux or systemd service instead.\n"
: "\nBackground mode is not supported by %s on *nix Systems. Please use screen/tmux or systemd service instead.\n", APP_NAME);
}
if (m_options->background()) {
Log::i()->text(Options::i()->colors()
? "\x1B[01;31m\nBackground mode is not supported by %s on *nix Systems. Please use screen/tmux or systemd service instead.\n"
: "\nBackground mode is not supported by %s on *nix Systems. Please use screen/tmux or systemd service instead.\n",
APP_NAME);
}
}

View file

@ -328,8 +328,8 @@ Options::Options(int argc, char **argv) :
parseConfig(Platform::defaultConfigName());
}
if (!m_pools[0]->isValid()) {
fprintf(stderr, "No pool URL supplied. Exiting.\n");
if (!m_pools[0]->isValid() && (!m_ccHost || m_ccPort == 0)) {
fprintf(stderr, "Neither pool nor CCServer URL supplied. Exiting.\n");
return;
}

View file

@ -22,6 +22,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <chrono>
#include <cstring>
#include <sstream>
#include <fstream>
@ -39,6 +40,7 @@
uv_mutex_t Service::m_mutex;
std::map<std::string, ControlCommand> Service::m_clientCommand;
std::map<std::string, ClientStatus> Service::m_clientStatus;
int Service::m_currentServerTime = 0;
bool Service::start()
{
@ -195,6 +197,10 @@ unsigned Service::getClientStatusList(std::string& resp)
clientStatusList.PushBack(clientStatusEntry, allocator);
}
auto time_point = std::chrono::system_clock::now();
m_currentServerTime = std::chrono::system_clock::to_time_t(time_point);
document.AddMember("current_server_time", m_currentServerTime, allocator);
document.AddMember("current_version", rapidjson::StringRef(Version::string().c_str()), allocator);
document.AddMember("client_status_list", clientStatusList, allocator);

View file

@ -58,6 +58,8 @@ private:
static std::string getClientConfigFileName(const Options *options, const std::string &clientId);
private:
static int m_currentServerTime;
static std::map<std::string, ClientStatus> m_clientStatus;
static std::map<std::string, ControlCommand> m_clientCommand;