Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
porto: refactor deamons and logging
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
  • Loading branch information
koct9i committed Aug 4, 2017
1 parent d75cf23 commit 4f4825e
Show file tree
Hide file tree
Showing 31 changed files with 250 additions and 429 deletions.
13 changes: 0 additions & 13 deletions debian/yandex-porto.logrotate
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,3 @@
endscript

}

/var/log/portoloop.log {
size 400M
missingok
rotate 7
compress
notifempty
nocreate

postrotate
[ -f /run/portoloop.pid ] && kill -USR1 `cat /run/portoloop.pid`
endscript
}
2 changes: 1 addition & 1 deletion scripts/standalone_test
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test $(id -u) = "0" || die "current user not root"
trap stop_porto TERM INT QUIT EXIT
kill_porto

rm -f /var/log/portod.log /var/log/portoloop.log
rm -f /var/log/portod.log

start_porto

Expand Down
2 changes: 1 addition & 1 deletion src/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ TError InitializeDaemonCgroups() {
return error;
}

// portod-slave
// portod
error = cg.Attach(GetPid());
if (error)
return error;
Expand Down
9 changes: 4 additions & 5 deletions src/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ constexpr const char *PORTO_VERSION_FILE = "/run/portod.version";
constexpr const char *PORTO_BINARY_PATH = "/run/portod";

constexpr const char *PORTO_MASTER_PIDFILE = "/run/portoloop.pid";
constexpr const char *PORTO_SLAVE_PIDFILE = "/run/portod.pid";
constexpr const char *PORTO_PIDFILE = "/run/portod.pid";

constexpr const char *PORTOD_MASTER_NAME = "portod";
constexpr const char *PORTOD_SLAVE_NAME = "portod-slave";
constexpr const char *PORTOD_MASTER_NAME = "portod-master";
constexpr const char *PORTOD_NAME = "portod";

constexpr const char *PORTO_MASTER_LOG = "/var/log/portoloop.log";
constexpr const char *PORTO_SLAVE_LOG = "/var/log/portod.log";
constexpr const char *PORTO_LOG = "/var/log/portod.log";

constexpr const char *PORTO_CONTAINERS_KV = "/run/porto/kvs";
constexpr const char *PORTO_VOLUMES_KV = "/run/porto/pkvs";
Expand Down
43 changes: 0 additions & 43 deletions src/config.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <iostream>

#include "config.hpp"
#include "protobuf.hpp"
#include "util/unix.hpp"
Expand Down Expand Up @@ -133,21 +131,6 @@ bool TConfig::LoadFile(const std::string &path) {
return true;
}

static void InitIpcSysctl() {
for (const auto &key: IpcSysctls) {
bool set = false;
for (const auto &it: config().container().ipc_sysctl())
set |= it.key() == key;
std::string val;
/* load default ipc sysctl from host config */
if (!set && !GetSysctl(key, val)) {
auto sysctl = config().mutable_container()->add_ipc_sysctl();
sysctl->set_key(key);
sysctl->set_val(val);
}
}
}

void TConfig::Load() {
LoadDefaults();

Expand All @@ -156,32 +139,6 @@ void TConfig::Load() {

Debug |= config().log().debug();
Verbose |= Debug | config().log().verbose();

InitCred();
InitCapabilities();
InitIpcSysctl();
}

int TConfig::Test(const std::string &path) {
TFile file;

if (access(path.c_str(), F_OK)) {
std::cerr << "Config " << path << " doesn't exist" << std::endl;
return EXIT_FAILURE;
}

if (file.OpenRead(path)) {
std::cerr << "Can't open " << path << std::endl;
return EXIT_FAILURE;
}

google::protobuf::io::FileInputStream pist(file.Fd);

cfg::TCfg cfg;
if (!google::protobuf::TextFormat::Merge(&pist, &cfg))
return EXIT_FAILURE;

return EXIT_SUCCESS;
}

cfg::TCfg &TConfig::operator()() {
Expand Down
1 change: 0 additions & 1 deletion src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class TConfig : public TNonCopyable {
public:
TConfig() {}
void Load();
int Test(const std::string &path);
cfg::TCfg &operator()();
};

Expand Down
2 changes: 0 additions & 2 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ class TEventWorker : public TWorker<TEvent, std::priority_queue<TEvent>> {
if (Top().DueMs <= now)
return;
auto timeout = Top().DueMs - now;
Statistics->SlaveTimeoutMs = timeout;
Cv.wait_for(lock, std::chrono::milliseconds(timeout));
} else {
Statistics->SlaveTimeoutMs = 0;
TWorker::Wait(lock);
}
}
Expand Down
Loading

0 comments on commit 4f4825e

Please sign in to comment.