Initial checkin for username creation

This commit is contained in:
stephb9959
2021-07-09 10:12:33 -07:00
parent 530a68c4ec
commit 0b7791aaa0
3 changed files with 25 additions and 0 deletions

View File

@@ -451,12 +451,25 @@ namespace uCentral {
return false;
}
void MicroService::SavePID() {
try {
std::ofstream O;
O.open(Daemon()->DataDir() + "/pidfile",std::ios::binary | std::ios::trunc);
O << Poco::Process::id();
O.close();
} catch (...)
{
std::cout << "Could not save system ID" << std::endl;
}
}
int MicroService::main(const ArgVec &args) {
MyErrorHandler ErrorHandler(*this);
Poco::ErrorHandler::set(&ErrorHandler);
if (!HelpRequested_) {
SavePID();
Poco::Logger &logger = Poco::Logger::get(DAEMON_APP_NAME);
logger.notice(Poco::format("Starting %s version %s.",DAEMON_APP_NAME, Version()));

View File

@@ -22,6 +22,7 @@
#include "Poco/Crypto/Cipher.h"
#include "Poco/SHA2Engine.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Process.h"
#include "uCentralTypes.h"
#include "SubSystemServer.h"
@@ -129,6 +130,9 @@ namespace uCentral {
[[nodiscard]] MicroServiceMetaVec GetServices();
[[nodiscard]] bool IsValidAPIKEY(const Poco::Net::HTTPServerRequest &Request);
void SavePID();
inline uint64_t GetPID() { return Poco::Process::id(); };
private:
bool HelpRequested_ = false;
std::string LogDir_;

8
stop.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
pidfilename="${UCENTRALSEC_ROOT}/data/pidfile"
if [[ -f "${pidfilename}" ]]
then
kill -9 $(cat ${pidfilename})
fi