[DEBUG] set zeus work again
This commit is contained in:
parent
bfe15a00fa
commit
1ae7682017
@ -97,15 +97,19 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::Path _path, etk::Map<et
|
||||
}
|
||||
etk::String storedSha512;
|
||||
if (etk::path::exist(_path + ".sha512") == true) {
|
||||
APPL_VERBOSE("file sha exist ==> read it");
|
||||
uint64_t time_sha512 = etk::path::getModifyTime(_path + ".sha512");
|
||||
uint64_t time_elem = etk::path::getModifyTime(_path);
|
||||
etk::io::File file(_path + ".sha512");
|
||||
file.open(etk::io::OpenMode::Read);
|
||||
etk::String storedSha512_file = file.readAllString();
|
||||
file.close();
|
||||
APPL_VERBOSE("file sha == " << storedSha512_file);
|
||||
if (time_elem > time_sha512) {
|
||||
APPL_VERBOSE("file time > sha time ==> regenerate new one ...");
|
||||
// check the current sha512
|
||||
storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path));
|
||||
APPL_VERBOSE("calculated new sha'" << storedSha512 << "'");
|
||||
if (storedSha512_file != storedSha512) {
|
||||
//need to remove the old sha file
|
||||
auto idFileToRemove_fut = _srv.getId(storedSha512_file).waitFor(echrono::seconds(2));
|
||||
@ -123,10 +127,14 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::Path _path, etk::Map<et
|
||||
file.close();
|
||||
} else {
|
||||
// store new sha512
|
||||
/*
|
||||
storedSha512 = file.readAllString();
|
||||
file.open(etk::io::OpenMode::Read);
|
||||
file.writeAll(storedSha512);
|
||||
file.close();
|
||||
*/
|
||||
storedSha512 = storedSha512_file;
|
||||
APPL_VERBOSE("read all sha from the file'" << storedSha512 << "'");
|
||||
}
|
||||
} else {
|
||||
storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path));
|
||||
@ -134,7 +142,9 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::Path _path, etk::Map<et
|
||||
file.open(etk::io::OpenMode::Write);
|
||||
file.writeAll(storedSha512);
|
||||
file.close();
|
||||
APPL_VERBOSE("calculate and store sha '" << storedSha512 << "'");
|
||||
}
|
||||
APPL_VERBOSE("check file existance: sha='" << storedSha512 << "'");
|
||||
// push only if the file exist
|
||||
// TODO : Check the metadata updating ...
|
||||
auto idFile_fut = _srv.getId(storedSha512).waitFor(echrono::seconds(2));
|
||||
@ -143,9 +153,12 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::Path _path, etk::Map<et
|
||||
return true;
|
||||
}
|
||||
// TODO: Do it better ==> add the calback to know the push progression ...
|
||||
auto sending = _srv.add(zeus::File::create(_path.getString(), storedSha512));
|
||||
APPL_VERBOSE("Add File : " << _path << " sha='" << storedSha512 << "'");
|
||||
auto sending = _srv.add(zeus::File::create(_path, storedSha512));
|
||||
sending.onSignal(progressCallback);
|
||||
APPL_VERBOSE("Add done ... now waiting ... ");
|
||||
uint32_t mediaId = sending.waitFor(echrono::seconds(20000)).get();
|
||||
APPL_VERBOSE("END WAITING ... ");
|
||||
if (mediaId == 0) {
|
||||
APPL_ERROR("Get media ID = 0 With no error");
|
||||
return false;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
#include <etk/Allocator.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
@ -28,7 +29,7 @@
|
||||
#include <zeus/Client.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
|
||||
typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::String _basePath);
|
||||
typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::Uri _basePath);
|
||||
typedef bool (*SERVICE_IO_uninit_t)();
|
||||
typedef void (*SERVICE_IO_peridic_call_t)();
|
||||
typedef zeus::Object* (*SERVICE_IO_instanciate_t)(uint32_t, ememory::SharedPtr<zeus::WebServer>&, uint32_t);
|
||||
@ -50,7 +51,7 @@ class PlugginAccess {
|
||||
m_SERVICE_IO_init(null),
|
||||
m_SERVICE_IO_uninit(null),
|
||||
m_SERVICE_IO_instanciate(null) {
|
||||
etk::Path srv = etk::path::getBinaryPath() / ".." / "lib" / "lib" / m_fullName + "-impl.so";
|
||||
etk::Path srv = etk::path::getBinaryDirectory() / ".." / "lib" / "lib" + m_fullName + "-impl.so";
|
||||
APPL_PRINT("++++++++++++++++++++++++++++++++");
|
||||
APPL_PRINT("++ srv: '" << m_name << "' ");
|
||||
APPL_PRINT("++++++++++++++++++++++++++++++++");
|
||||
@ -90,16 +91,15 @@ class PlugginAccess {
|
||||
~PlugginAccess() {
|
||||
|
||||
}
|
||||
bool init(int _argc, const char *_argv[], etk::String _basePath) {
|
||||
bool init(int _argc, const char *_argv[], etk::Uri _basePath) {
|
||||
if (m_SERVICE_IO_init == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_basePath.size() == 0) {
|
||||
_basePath = "USERDATA:" + m_name + "/";
|
||||
if (_basePath.isEmpty() == true) {
|
||||
_basePath = "USER_DATA:///" + m_name;
|
||||
APPL_PRINT("Use base path: " << _basePath);
|
||||
} else {
|
||||
_basePath += m_name + "/";
|
||||
_basePath /= m_name;
|
||||
}
|
||||
return (*m_SERVICE_IO_init)(_argc, _argv, _basePath);
|
||||
}
|
||||
@ -137,7 +137,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
zeus::init(_argc, _argv);
|
||||
appl::GateWay basicGateway;
|
||||
#ifdef GATEWAY_ENABLE_LAUNCHER
|
||||
etk::String basePath;
|
||||
etk::Uri basePath;
|
||||
etk::Vector<etk::String> services;
|
||||
zeus::Client m_client;
|
||||
// The default service port is 1985
|
||||
@ -188,11 +188,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
basicGateway.propertyServiceMax.set(etk::string_to_uint16_t(etk::String(&data[14])));
|
||||
#ifdef GATEWAY_ENABLE_LAUNCHER
|
||||
} else if (etk::start_with(data, "--base-path=") == true) {
|
||||
basePath = etk::String(&data[12]);
|
||||
if ( basePath.size() != 0
|
||||
&& basePath[basePath.size()-1] != '/') {
|
||||
basePath += '/';
|
||||
}
|
||||
basePath = etk::Path(etk::String(&data[12]));
|
||||
} else if (etk::start_with(data, "--srv=") == true) {
|
||||
services.pushBack(etk::String(&data[6]));
|
||||
#endif
|
||||
@ -223,7 +219,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::Vector<etk::Pair<etk::String,etk::String>> listAvaillableServices;
|
||||
if (services.size() != 0) {
|
||||
// find all services:
|
||||
etk::Path dataPath(etk::path::getBinaryPath() / ".." / "share");
|
||||
etk::Path dataPath(etk::path::getBinaryDirectory() / ".." / "share");
|
||||
etk::Vector<etk::Path> listSubPath = etk::path::list(dataPath, etk::path::LIST_FOLDER);
|
||||
APPL_DEBUG(" Base data path: " << dataPath);
|
||||
APPL_DEBUG(" SubPath: " << listSubPath);
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
|
||||
static etk::Path g_pathDBName = "USER_DATA:///router-database.json";
|
||||
static etk::Uri g_pathDBName = "USER_DATA:///router-database.json";
|
||||
|
||||
class UserAvaillable {
|
||||
public:
|
||||
@ -186,6 +186,7 @@ extern "C" {
|
||||
|
||||
ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const etk::String& _userName) {
|
||||
// TODO : Start USer only when needed, not get it all time started...
|
||||
APPL_ERROR("Get user : " << _userName);
|
||||
for (auto &it : m_GateWayList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
@ -193,91 +194,96 @@ ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const etk::String&
|
||||
if (it->getName() != _userName) {
|
||||
continue;
|
||||
}
|
||||
APPL_ERROR(" ==> find IT ... already started...");
|
||||
return it;
|
||||
}
|
||||
APPL_ERROR(" ==> Not found ==> start it ...");
|
||||
// we not find the user ==> check if it is availlable ...
|
||||
for (auto &it : g_listUserAvaillable) {
|
||||
if (it.m_name == _userName) {
|
||||
#if 0
|
||||
// start interface:
|
||||
etk::String cmd = "~/dev/perso/out/Linux_x86_64/debug/staging/clang/zeus-package-base/zeus-package-base.app/bin/zeus-gateway";
|
||||
cmd += " --user=" + it.m_name + " ";
|
||||
cmd += " --srv=user";
|
||||
cmd += " --srv=picture";
|
||||
cmd += " --srv=video";
|
||||
cmd += " --base-path=" + it.m_basePath;
|
||||
cmd += " --elog-file=\"/tmp/zeus.gateway." + it.m_name + ".log\"";
|
||||
cmd += "&";
|
||||
APPL_ERROR("Start " << cmd);
|
||||
it.m_subProcess = popen(cmd.c_str(), "r");
|
||||
if (it.m_subProcess == null) {
|
||||
perror("popen");
|
||||
return null;
|
||||
}
|
||||
// just trash IO ...
|
||||
//pclose(it.m_subProcess);
|
||||
#else
|
||||
if (fork()) {
|
||||
// We're in the parent here.
|
||||
// nothing to do ...
|
||||
APPL_ERROR("Parent Execution ...");
|
||||
} else {
|
||||
// We're in the child here.
|
||||
APPL_ERROR("Child Execution ...");
|
||||
etk::Path binary = etk::path::getBinaryPath() / "zeus-gateway";
|
||||
etk::String userConf = "--user=" + it.m_name;
|
||||
etk::String basePath = "--base-path=" + it.m_basePath;
|
||||
etk::String logFile;
|
||||
if (*propertyStdOut == false) {
|
||||
etk::Path tmp = etk::Path(it.m_basePath) / "log" / "gateway.log";
|
||||
if ( tmp.isEmpty() == false
|
||||
&& tmp.getString()[0] == '~') {
|
||||
tmp = etk::path::getHomePath() / &logFile[1];
|
||||
}
|
||||
logFile = "--elog-file=" + tmp.getString();
|
||||
//etk::String logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log";
|
||||
//etk::String logFile = " ";
|
||||
APPL_INFO("New Child log in = " << logFile);
|
||||
}
|
||||
etk::String directAccess;
|
||||
if (it.m_enableDirectAccess == true) {
|
||||
directAccess = "--direct-ip=" + *propertyClientIp;
|
||||
directAccess += " --direct-port=" + etk::toString(*propertyGateWayDirectPortMin);
|
||||
}
|
||||
etk::String delay = "--router-delay=" + etk::toString(*propertyDelayToStop);
|
||||
//etk::String delay = "--router-delay=-1";
|
||||
APPL_INFO("execute: " << binary << " " << userConf << " --srv=all " << delay << " " << basePath << " " << logFile << " " << directAccess);
|
||||
int ret = execlp( binary.getNative().c_str(),
|
||||
binary.getNative().c_str(), // must repeate the binary name to have the name as first argument ...
|
||||
userConf.c_str(),
|
||||
"--srv=all",
|
||||
"--service-extern=false",
|
||||
delay.c_str(),
|
||||
basePath.c_str(),
|
||||
logFile.c_str(),
|
||||
directAccess.c_str(),
|
||||
NULL);
|
||||
APPL_ERROR("Child Execution ret = " << ret);
|
||||
exit (-1);
|
||||
APPL_ERROR("Must never appear ... child of fork killed ...");
|
||||
}
|
||||
#endif
|
||||
int32_t nbCheckDelayMax = 24;
|
||||
while (nbCheckDelayMax-- > 0) {
|
||||
ethread::sleepMilliSeconds((25));
|
||||
for (auto &it : m_GateWayList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() != _userName) {
|
||||
continue;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
}
|
||||
APPL_ERROR("must be connected ==> and it is not ...");
|
||||
break;
|
||||
APPL_ERROR(" Check: " << it.m_name << " != " << _userName);
|
||||
if (it.m_name != _userName) {
|
||||
continue;
|
||||
}
|
||||
APPL_ERROR(" ==> find ...");
|
||||
#if 0
|
||||
// start interface:
|
||||
etk::String cmd = "~/dev/perso/out/Linux_x86_64/debug/staging/clang/zeus-package-base/zeus-package-base.app/bin/zeus-gateway";
|
||||
cmd += " --user=" + it.m_name + " ";
|
||||
cmd += " --srv=user";
|
||||
cmd += " --srv=picture";
|
||||
cmd += " --srv=video";
|
||||
cmd += " --base-path=" + it.m_basePath;
|
||||
cmd += " --elog-file=\"/tmp/zeus.gateway." + it.m_name + ".log\"";
|
||||
cmd += "&";
|
||||
APPL_ERROR("Start " << cmd);
|
||||
it.m_subProcess = popen(cmd.c_str(), "r");
|
||||
if (it.m_subProcess == null) {
|
||||
perror("popen");
|
||||
return null;
|
||||
}
|
||||
// just trash IO ...
|
||||
//pclose(it.m_subProcess);
|
||||
#else
|
||||
if (fork()) {
|
||||
// We're in the parent here.
|
||||
// nothing to do ...
|
||||
APPL_ERROR("Parent Execution ...");
|
||||
} else {
|
||||
// We're in the child here.
|
||||
APPL_ERROR("Child Execution ...");
|
||||
etk::Path binary = etk::path::getBinaryDirectory() / "zeus-gateway";
|
||||
etk::String userConf = "--user=" + it.m_name;
|
||||
etk::String basePath = "--base-path=" + it.m_basePath;
|
||||
etk::String logFile;
|
||||
if (*propertyStdOut == false) {
|
||||
etk::Path tmp = etk::Path(it.m_basePath) / "log" / "gateway.log";
|
||||
if ( tmp.isEmpty() == false
|
||||
&& tmp.getString()[0] == '~') {
|
||||
tmp = etk::path::getHomePath() / &logFile[1];
|
||||
}
|
||||
logFile = "--elog-file=" + tmp.getString();
|
||||
//etk::String logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log";
|
||||
//etk::String logFile = " ";
|
||||
APPL_INFO("New Child log in = " << logFile);
|
||||
}
|
||||
etk::String directAccess;
|
||||
if (it.m_enableDirectAccess == true) {
|
||||
directAccess = "--direct-ip=" + *propertyClientIp;
|
||||
directAccess += " --direct-port=" + etk::toString(*propertyGateWayDirectPortMin);
|
||||
}
|
||||
etk::String delay = "--router-delay=" + etk::toString(*propertyDelayToStop);
|
||||
//etk::String delay = "--router-delay=-1";
|
||||
APPL_INFO("execute: " << binary << " " << userConf << " --srv=all " << delay << " " << basePath << " " << logFile << " " << directAccess);
|
||||
int ret = execlp( binary.getNative().c_str(),
|
||||
binary.getNative().c_str(), // must repeate the binary name to have the name as first argument ...
|
||||
userConf.c_str(),
|
||||
"--srv=all",
|
||||
"--service-extern=false",
|
||||
delay.c_str(),
|
||||
basePath.c_str(),
|
||||
logFile.c_str(),
|
||||
directAccess.c_str(),
|
||||
NULL);
|
||||
APPL_ERROR("Child Execution ret = " << ret);
|
||||
exit (-1);
|
||||
APPL_ERROR("Must never appear ... child of fork killed ...");
|
||||
}
|
||||
#endif
|
||||
int32_t nbCheckDelayMax = 24;
|
||||
while (nbCheckDelayMax-- > 0) {
|
||||
ethread::sleepMilliSeconds((25));
|
||||
for (auto &it : m_GateWayList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() != _userName) {
|
||||
continue;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
}
|
||||
APPL_ERROR("must be connected ==> and it is not ...");
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ zeus::FileImpl::FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName,
|
||||
m_gettedData(0),
|
||||
m_mineType(_mineType),
|
||||
m_sha512("") {
|
||||
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
|
||||
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE 1 " << _virtualName);
|
||||
m_dataRaw = true;
|
||||
m_data = _value;
|
||||
m_size = m_data.size();
|
||||
@ -52,7 +52,7 @@ zeus::FileImpl::FileImpl(etk::Uri _fileNameReal, etk::String _sha512) :
|
||||
m_file(etk::uri::get(_fileNameReal)),
|
||||
m_gettedData(0),
|
||||
m_sha512(_sha512) {
|
||||
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
|
||||
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE 3 " << _fileNameReal << " '" << _sha512 << "' size=" << m_file->size());
|
||||
m_size = m_file->size();
|
||||
etk::String extention = _fileNameReal.getPath().getExtention();
|
||||
m_mineType = zeus::getMineType(extention);
|
||||
@ -71,7 +71,7 @@ zeus::FileImpl::FileImpl(etk::Uri _fileNameReal, etk::String _fileNameShow, etk:
|
||||
m_gettedData(0),
|
||||
m_mineType(_mineType),
|
||||
m_sha512(_sha512) {
|
||||
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
|
||||
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE 2 " << _fileNameReal);
|
||||
m_size = m_file->size();
|
||||
if ( _sha512.size() > 0
|
||||
&& _sha512.size() != 128) {
|
||||
@ -96,6 +96,7 @@ etk::String zeus::FileImpl::getName() {
|
||||
}
|
||||
|
||||
etk::String zeus::FileImpl::getSha512() {
|
||||
ZEUS_VERBOSE("Get SHA 512 ... " << m_sha512.size() << " '" << m_sha512 << "'");
|
||||
if (m_sha512 == "") {
|
||||
ZEUS_INFO("calculation of sha 512 (start)");
|
||||
if (m_dataRaw == false) {
|
||||
@ -105,6 +106,7 @@ etk::String zeus::FileImpl::getSha512() {
|
||||
}
|
||||
ZEUS_INFO("calculation of sha 512 (stop)");
|
||||
}
|
||||
ZEUS_VERBOSE("return sha512 : '" << m_sha512 << "'");
|
||||
return m_sha512;
|
||||
}
|
||||
|
||||
@ -113,6 +115,7 @@ etk::String zeus::FileImpl::getMineType() {
|
||||
}
|
||||
|
||||
zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
|
||||
ZEUS_VERBOSE("REQUEST Get part ... " << _start << " " << _stop);
|
||||
if ((_stop - _start) > 25*1024*1024) {
|
||||
ZEUS_ERROR("REQUEST more that 25 Mo in a part file ...");
|
||||
throw etk::exception::InvalidArgument("REQUEST more that 25 Mo in a part file ..." + etk::toString(_stop - _start) + " Bytes");
|
||||
@ -172,8 +175,10 @@ etk::String zeus::storeInFileNotify(zeus::ProxyFile _file, etk::Uri _uri, zeus::
|
||||
nbElement = retSize;
|
||||
}
|
||||
auto futData = _file.getPart(offset, offset + nbElement);
|
||||
// TODO: set a timeout
|
||||
futData.wait();
|
||||
if (futData.hasError() == true) {
|
||||
ZEUS_DEBUG("read: ==> exception when read data ...");
|
||||
throw etk::exception::RuntimeError("Error when loading data");
|
||||
}
|
||||
zeus::Raw buffer = futData.get();
|
||||
|
Loading…
x
Reference in New Issue
Block a user