mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
console ouput supported instruction sets
This commit is contained in:
parent
60540f810f
commit
f19ed761e2
1 changed files with 67 additions and 61 deletions
128
main.cpp
128
main.cpp
|
|
@ -28,77 +28,83 @@ void SaveSig(int s)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::cout << "\nSSE3 : " << (__builtin_cpu_supports("sse3") ? "enabled" : "disabled")
|
std::cout
|
||||||
<< "\nThreads : " << get_nprocs() + 1
|
<< "\nAVX : " << (__builtin_cpu_supports("avx") ? "enabled" : "disabled")
|
||||||
<< std::endl; //flushing before EventLoop
|
<< "\nAVX 2 : " << (__builtin_cpu_supports("avx2") ? "enabled" : "disabled")
|
||||||
|
<< "\nSSE 2 : " << (__builtin_cpu_supports("sse2") ? "enabled" : "disabled")
|
||||||
|
<< "\nSSE 3 : " << (__builtin_cpu_supports("sse3") ? "enabled" : "disabled")
|
||||||
|
<< "\nSSE 4.1 : " << (__builtin_cpu_supports("sse4.1") ? "enabled" : "disabled")
|
||||||
|
<< "\nSSE 4.2 : " << (__builtin_cpu_supports("sse4.2") ? "enabled" : "disabled")
|
||||||
|
<< "\n\nThreads : " << get_nprocs() + 1
|
||||||
|
<< std::endl; //flushing before EventLoop
|
||||||
|
|
||||||
static_assert(bool(MAX_LOG_SIZE) == bool(PRE_LOG_SIZE), "You must either utilize both or neither logging variables.\n");
|
// static_assert(bool(MAX_LOG_SIZE) == bool(PRE_LOG_SIZE), "You must either utilize both or neither logging variables.\n");
|
||||||
static_assert(MAX_LOG_SIZE >= PRE_LOG_SIZE, "The maximum log size must be larger than or equal to the amount preallocated.\n");
|
// static_assert(MAX_LOG_SIZE >= PRE_LOG_SIZE, "The maximum log size must be larger than or equal to the amount preallocated.\n");
|
||||||
static_assert(!MAX_LOG_SIZE || !(MAX_LOG_SIZE % PRE_LOG_SIZE), "The maximum log size must be divisible by the preallocation size.\n");
|
// static_assert(!MAX_LOG_SIZE || !(MAX_LOG_SIZE % PRE_LOG_SIZE), "The maximum log size must be divisible by the preallocation size.\n");
|
||||||
|
|
||||||
if (argc != 3)
|
// if (argc != 3)
|
||||||
{
|
// {
|
||||||
std::cerr << "Usage: sudo ./bank <admin password> <saving frequency in minutes>\n";
|
// std::cerr << "Usage: sudo ./bank <admin password> <saving frequency in minutes>\n";
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
if (geteuid() != 0)
|
// if (geteuid() != 0)
|
||||||
{
|
// {
|
||||||
std::cerr << "ERROR: CCash MUST be ran as root\n";
|
// std::cerr << "ERROR: CCash MUST be ran as root\n";
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Loading users from users.json
|
// //Loading users from users.json
|
||||||
bank.Load();
|
// bank.Load();
|
||||||
|
|
||||||
//Sig handling
|
// //Sig handling
|
||||||
struct sigaction sigIntHandler;
|
// struct sigaction sigIntHandler;
|
||||||
|
|
||||||
sigIntHandler.sa_handler = SaveSig;
|
// sigIntHandler.sa_handler = SaveSig;
|
||||||
sigemptyset(&sigIntHandler.sa_mask);
|
// sigemptyset(&sigIntHandler.sa_mask);
|
||||||
sigIntHandler.sa_flags = 0;
|
// sigIntHandler.sa_flags = 0;
|
||||||
|
|
||||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
// sigaction(SIGINT, &sigIntHandler, NULL);
|
||||||
|
|
||||||
//Admin Password
|
// //Admin Password
|
||||||
bank.admin_pass = argv[1];
|
// bank.admin_pass = argv[1];
|
||||||
|
|
||||||
//Auto Saving
|
// //Auto Saving
|
||||||
const unsigned long saving_freq = std::stoul(std::string(argv[2]));
|
// const unsigned long saving_freq = std::stoul(std::string(argv[2]));
|
||||||
if (saving_freq) //if saving frequency is 0 then auto saving is turned off
|
// if (saving_freq) //if saving frequency is 0 then auto saving is turned off
|
||||||
{
|
// {
|
||||||
std::thread([saving_freq]() {
|
// std::thread([saving_freq]() {
|
||||||
while (1)
|
// while (1)
|
||||||
{
|
// {
|
||||||
std::this_thread::sleep_for(std::chrono::minutes(saving_freq));
|
// std::this_thread::sleep_for(std::chrono::minutes(saving_freq));
|
||||||
std::cout << "Saving " << std::time(0) << '\n';
|
// std::cout << "Saving " << std::time(0) << '\n';
|
||||||
if (bank.GetChangeState())
|
// if (bank.GetChangeState())
|
||||||
{
|
// {
|
||||||
std::cout << " to disk...\n";
|
// std::cout << " to disk...\n";
|
||||||
bank.Save();
|
// bank.Save();
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
std::cout << " no changes...\n";
|
// std::cout << " no changes...\n";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}).detach();
|
// }).detach();
|
||||||
}
|
// }
|
||||||
|
|
||||||
auto API = std::make_shared<api>(bank);
|
// auto API = std::make_shared<api>(bank);
|
||||||
auto user_filter = std::make_shared<UserFilter>(bank);
|
// auto user_filter = std::make_shared<UserFilter>(bank);
|
||||||
auto admin_filter = std::make_shared<AdminFilter>(bank);
|
// auto admin_filter = std::make_shared<AdminFilter>(bank);
|
||||||
|
|
||||||
app().registerPostHandlingAdvice(
|
// app().registerPostHandlingAdvice(
|
||||||
[](const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &resp) {
|
// [](const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &resp) {
|
||||||
resp->addHeader("Access-Control-Allow-Origin", "*"); //CORS
|
// resp->addHeader("Access-Control-Allow-Origin", "*"); //CORS
|
||||||
});
|
// });
|
||||||
app()
|
// app()
|
||||||
.loadConfigFile(config_location)
|
// .loadConfigFile(config_location)
|
||||||
.registerFilter(user_filter)
|
// .registerFilter(user_filter)
|
||||||
.registerFilter(admin_filter)
|
// .registerFilter(admin_filter)
|
||||||
.registerController(API)
|
// .registerController(API)
|
||||||
.setThreadNum(get_nprocs())
|
// .setThreadNum(get_nprocs())
|
||||||
.run();
|
// .run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue