Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (6)
master
feature/48-mysql-connection-pool
gh-pages
bugfix/52-volume-already-in-use
feature/6-simplify-deployment
async-rewrite
master
Branches (6)
master
feature/48-mysql-connection-pool
gh-pages
bugfix/52-volume-already-in-use
feature/6-simplify-deployment
async-rewrite
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (6)
master
feature/48-mysql-connection-pool
gh-pages
bugfix/52-volume-already-in-use
feature/6-simplify-deployment
async-rewrite
main.cpp 2.53 KB
Copy Edit Raw Blame History
Ruben Perez authored 2023年09月26日 23:21 +08:00 . Authentication, login and account creation
//
// Copyright (c) 2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/asio/io_context.hpp>
#include <boost/asio/signal_set.hpp>
#include <cstdlib>
#include <iostream>
#include <string>
#include "error.hpp"
#include "listener.hpp"
#include "services/redis_client.hpp"
#include "shared_state.hpp"
using namespace chat;
int main(int argc, char* argv[])
{
// Check command line arguments.
if (argc != 4)
{
std::cerr << "Usage: " << argv[0] << " <address> <port> <doc_root>\n"
<< "Example:\n"
<< " " << argv[0] << " 0.0.0.0 8080 .\n";
return EXIT_FAILURE;
}
// Application config
const char* doc_root = argv[3]; // Path to static files
const char* ip = argv[1]; // IP where the server will listen
auto port = static_cast<unsigned short>(std::atoi(argv[2])); // Port
// An event loop, where the application will run. The server is single-
// threaded, so we set the concurrency hint to 1
boost::asio::io_context ioc{1};
// Singleton objects shared by all connections
auto st = std::make_shared<shared_state>(doc_root, ioc.get_executor());
// The physical endpoint where our server will listen
boost::asio::ip::tcp::endpoint listening_endpoint{boost::asio::ip::make_address(ip), port};
// A signal_set allows us to intercept SIGINT and SIGTERM and
// exit gracefully
boost::asio::signal_set signals{ioc.get_executor(), SIGINT, SIGTERM};
// Launch the Redis connection
st->redis().start_run();
// Start listening for HTTP connections. This will run until the context is stopped
auto ec = launch_http_listener(ioc.get_executor(), listening_endpoint, st);
if (ec)
{
log_error(ec, "Error launching the HTTP listener");
exit(EXIT_FAILURE);
}
// Capture SIGINT and SIGTERM to perform a clean shutdown
signals.async_wait([st, &ioc](error_code, int) {
// Stop the Redis reconnection loop
st->redis().cancel();
// Stop the io_context. This will cause run() to return
ioc.stop();
});
// Run the io_context. This will block until the context is stopped by
// a signal and all outstanding async tasks are finished.
ioc.run();
// (If we get here, it means we got a SIGINT or SIGTERM)
return EXIT_SUCCESS;
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cppprojects/servertech-chat.git
git@gitee.com:cppprojects/servertech-chat.git
cppprojects
servertech-chat
servertech-chat
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /