update config files deploy.
Some checks failed
Deploy / Build (push) Failing after 34s

This commit is contained in:
luocai 2024-11-20 14:55:56 +08:00
parent 30185e9ff1
commit abea92c348
10 changed files with 246 additions and 207 deletions

View File

@ -4,7 +4,7 @@ ObjCBlockIndentWidth: 4
IndentWidth: 4 IndentWidth: 4
TabWidth: 4 TabWidth: 4
AccessModifierOffset: -4 AccessModifierOffset: -4
ColumnLimit: 120 ColumnLimit: 130
#模板声明后换行 #模板声明后换行
AlwaysBreakTemplateDeclarations: true AlwaysBreakTemplateDeclarations: true

View File

@ -5,6 +5,7 @@ on:
paths: paths:
- '**.cpp' - '**.cpp'
- '**.h' - '**.h'
- '**.conf'
jobs: jobs:
Build: Build:
runs-on: [ubuntu-latest, ubuntu-24.04] runs-on: [ubuntu-latest, ubuntu-24.04]
@ -59,6 +60,24 @@ jobs:
cp /tmp/HttpServer /root/Server/HttpServer cp /tmp/HttpServer /root/Server/HttpServer
nohup /root/Server/HttpServer > /dev/null 2>&1 & nohup /root/Server/HttpServer > /dev/null 2>&1 &
exit 0 exit 0
- name: Copy openresty configuration files to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ vars.YUYUN_SERVER }}
username: ${{ vars.YUYUN_USER }}
password: ${{ secrets.SERVER_ROOT_PASSWORD }}
overwrite: true
strip_components: 1
source: Server/conf
target: /root/Server
- name: Restart openresty
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ vars.YUYUN_SERVER }}
username: ${{ vars.YUYUN_USER }}
password: ${{ secrets.SERVER_ROOT_PASSWORD }}
script: |
systemctl restart openresty.service
- name: Notify-End - name: Notify-End
if: ${{ always() }} if: ${{ always() }}
run: | run: |

View File

@ -27,6 +27,7 @@ public:
BUILD_SETTING(std::string, Server, "0.0.0.0"); BUILD_SETTING(std::string, Server, "0.0.0.0");
BUILD_SETTING(uint16_t, Port, 8081); BUILD_SETTING(uint16_t, Port, 8081);
BUILD_SETTING(uint16_t, WtPort, 8082);
BUILD_SETTING(uint32_t, Threads, std::thread::hardware_concurrency()); BUILD_SETTING(uint32_t, Threads, std::thread::hardware_concurrency());
BUILD_SETTING(std::string, DocumentRoot, "."); BUILD_SETTING(std::string, DocumentRoot, ".");
BUILD_SETTING(std::string, Sqlte3Path, "database.sqlite"); BUILD_SETTING(std::string, Sqlte3Path, "database.sqlite");

View File

@ -1,97 +1,99 @@
types { types {
text/html html htm shtml; text/html html htm shtml;
text/css css; text/css css;
text/xml xml; text/xml xml;
image/gif gif; image/gif gif;
image/jpeg jpeg jpg; image/jpeg jpeg jpg;
application/javascript js; application/javascript js;
application/atom+xml atom; application/atom+xml atom;
application/rss+xml rss; application/rss+xml rss;
text/mathml mml; text/mathml mml;
text/plain txt; text/plain txt;
text/vnd.sun.j2me.app-descriptor jad; text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml; text/vnd.wap.wml wml;
text/x-component htc; text/x-component htc;
image/png png; image/avif avif;
image/svg+xml svg svgz; image/png png;
image/tiff tif tiff; image/svg+xml svg svgz;
image/vnd.wap.wbmp wbmp; image/tiff tif tiff;
image/webp webp; image/vnd.wap.wbmp wbmp;
image/x-icon ico; image/webp webp;
image/x-jng jng; image/x-icon ico;
image/x-ms-bmp bmp; image/x-jng jng;
image/x-ms-bmp bmp;
font/woff woff;
font/woff2 woff2; font/woff woff;
font/woff2 woff2;
application/java-archive jar war ear;
application/json json; application/java-archive jar war ear;
application/mac-binhex40 hqx; application/json json;
application/msword doc; application/mac-binhex40 hqx;
application/pdf pdf; application/msword doc;
application/postscript ps eps ai; application/pdf pdf;
application/rtf rtf; application/postscript ps eps ai;
application/vnd.apple.mpegurl m3u8; application/rtf rtf;
application/vnd.google-earth.kml+xml kml; application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kmz kmz; application/vnd.google-earth.kml+xml kml;
application/vnd.ms-excel xls; application/vnd.google-earth.kmz kmz;
application/vnd.ms-fontobject eot; application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt; application/vnd.ms-fontobject eot;
application/vnd.oasis.opendocument.graphics odg; application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.presentation odp; application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.spreadsheet ods; application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.text odt; application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.oasis.opendocument.text odt;
pptx; application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet pptx;
xlsx; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.wordprocessingml.document xlsx;
docx; application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.wap.wmlc wmlc; docx;
application/x-7z-compressed 7z; application/vnd.wap.wmlc wmlc;
application/x-cocoa cco; application/wasm wasm;
application/x-java-archive-diff jardiff; application/x-7z-compressed 7z;
application/x-java-jnlp-file jnlp; application/x-cocoa cco;
application/x-makeself run; application/x-java-archive-diff jardiff;
application/x-perl pl pm; application/x-java-jnlp-file jnlp;
application/x-pilot prc pdb; application/x-makeself run;
application/x-rar-compressed rar; application/x-perl pl pm;
application/x-redhat-package-manager rpm; application/x-pilot prc pdb;
application/x-sea sea; application/x-rar-compressed rar;
application/x-shockwave-flash swf; application/x-redhat-package-manager rpm;
application/x-stuffit sit; application/x-sea sea;
application/x-tcl tcl tk; application/x-shockwave-flash swf;
application/x-x509-ca-cert der pem crt; application/x-stuffit sit;
application/x-xpinstall xpi; application/x-tcl tcl tk;
application/xhtml+xml xhtml; application/x-x509-ca-cert der pem crt;
application/xspf+xml xspf; application/x-xpinstall xpi;
application/zip zip; application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/octet-stream bin exe dll; application/zip zip;
application/octet-stream deb;
application/octet-stream dmg; application/octet-stream bin exe dll;
application/octet-stream iso img; application/octet-stream deb;
application/octet-stream msi msp msm; application/octet-stream dmg;
application/octet-stream iso img;
audio/midi mid midi kar; application/octet-stream msi msp msm;
audio/mpeg mp3;
audio/ogg ogg; audio/midi mid midi kar;
audio/x-m4a m4a; audio/mpeg mp3;
audio/x-realaudio ra; audio/ogg ogg;
audio/x-m4a m4a;
video/3gpp 3gpp 3gp; audio/x-realaudio ra;
video/mp2t ts;
video/mp4 mp4; video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg; video/mp2t ts;
video/quicktime mov; video/mp4 mp4;
video/webm webm; video/mpeg mpeg mpg;
video/x-flv flv; video/quicktime mov;
video/x-m4v m4v; video/webm webm;
video/x-mng mng; video/x-flv flv;
video/x-ms-asf asx asf; video/x-m4v m4v;
video/x-ms-wmv wmv; video/x-mng mng;
video/x-msvideo avi; video/x-ms-asf asx asf;
} video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@ -1,97 +1,99 @@
types { types {
text/html html htm shtml; text/html html htm shtml;
text/css css; text/css css;
text/xml xml; text/xml xml;
image/gif gif; image/gif gif;
image/jpeg jpeg jpg; image/jpeg jpeg jpg;
application/javascript js; application/javascript js;
application/atom+xml atom; application/atom+xml atom;
application/rss+xml rss; application/rss+xml rss;
text/mathml mml; text/mathml mml;
text/plain txt; text/plain txt;
text/vnd.sun.j2me.app-descriptor jad; text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml; text/vnd.wap.wml wml;
text/x-component htc; text/x-component htc;
image/png png; image/avif avif;
image/svg+xml svg svgz; image/png png;
image/tiff tif tiff; image/svg+xml svg svgz;
image/vnd.wap.wbmp wbmp; image/tiff tif tiff;
image/webp webp; image/vnd.wap.wbmp wbmp;
image/x-icon ico; image/webp webp;
image/x-jng jng; image/x-icon ico;
image/x-ms-bmp bmp; image/x-jng jng;
image/x-ms-bmp bmp;
font/woff woff;
font/woff2 woff2; font/woff woff;
font/woff2 woff2;
application/java-archive jar war ear;
application/json json; application/java-archive jar war ear;
application/mac-binhex40 hqx; application/json json;
application/msword doc; application/mac-binhex40 hqx;
application/pdf pdf; application/msword doc;
application/postscript ps eps ai; application/pdf pdf;
application/rtf rtf; application/postscript ps eps ai;
application/vnd.apple.mpegurl m3u8; application/rtf rtf;
application/vnd.google-earth.kml+xml kml; application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kmz kmz; application/vnd.google-earth.kml+xml kml;
application/vnd.ms-excel xls; application/vnd.google-earth.kmz kmz;
application/vnd.ms-fontobject eot; application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt; application/vnd.ms-fontobject eot;
application/vnd.oasis.opendocument.graphics odg; application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.presentation odp; application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.spreadsheet ods; application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.text odt; application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.oasis.opendocument.text odt;
pptx; application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet pptx;
xlsx; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.wordprocessingml.document xlsx;
docx; application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.wap.wmlc wmlc; docx;
application/x-7z-compressed 7z; application/vnd.wap.wmlc wmlc;
application/x-cocoa cco; application/wasm wasm;
application/x-java-archive-diff jardiff; application/x-7z-compressed 7z;
application/x-java-jnlp-file jnlp; application/x-cocoa cco;
application/x-makeself run; application/x-java-archive-diff jardiff;
application/x-perl pl pm; application/x-java-jnlp-file jnlp;
application/x-pilot prc pdb; application/x-makeself run;
application/x-rar-compressed rar; application/x-perl pl pm;
application/x-redhat-package-manager rpm; application/x-pilot prc pdb;
application/x-sea sea; application/x-rar-compressed rar;
application/x-shockwave-flash swf; application/x-redhat-package-manager rpm;
application/x-stuffit sit; application/x-sea sea;
application/x-tcl tcl tk; application/x-shockwave-flash swf;
application/x-x509-ca-cert der pem crt; application/x-stuffit sit;
application/x-xpinstall xpi; application/x-tcl tcl tk;
application/xhtml+xml xhtml; application/x-x509-ca-cert der pem crt;
application/xspf+xml xspf; application/x-xpinstall xpi;
application/zip zip; application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/octet-stream bin exe dll; application/zip zip;
application/octet-stream deb;
application/octet-stream dmg; application/octet-stream bin exe dll;
application/octet-stream iso img; application/octet-stream deb;
application/octet-stream msi msp msm; application/octet-stream dmg;
application/octet-stream iso img;
audio/midi mid midi kar; application/octet-stream msi msp msm;
audio/mpeg mp3;
audio/ogg ogg; audio/midi mid midi kar;
audio/x-m4a m4a; audio/mpeg mp3;
audio/x-realaudio ra; audio/ogg ogg;
audio/x-m4a m4a;
video/3gpp 3gpp 3gp; audio/x-realaudio ra;
video/mp2t ts;
video/mp4 mp4; video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg; video/mp2t ts;
video/quicktime mov; video/mp4 mp4;
video/webm webm; video/mpeg mpeg mpg;
video/x-flv flv; video/quicktime mov;
video/x-m4v m4v; video/webm webm;
video/x-mng mng; video/x-flv flv;
video/x-ms-asf asx asf; video/x-m4v m4v;
video/x-ms-wmv wmv; video/x-mng mng;
video/x-msvideo avi; video/x-ms-asf asx asf;
} video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@ -26,7 +26,7 @@ http {
keepalive_timeout 65; keepalive_timeout 65;
gzip on; gzip on;
gzip_types application/octet-stream text/markdown text/plain application/json application/x-javascript text/css application/xml text/javascript application/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_types application/octet-stream text/markdown text/plain application/json application/x-javascript text/css application/xml text/javascript application/javascript application/x-httpd-php application/text image/jpeg image/gif image/png;
# 定义一个限流区域,名称为 one大小为 10MB限速为每 5 分钟 5 次请求 # 定义一个限流区域,名称为 one大小为 10MB限速为每 5 分钟 5 次请求
limit_req_zone $binary_remote_addr zone=one:10m rate=3r/m; limit_req_zone $binary_remote_addr zone=one:10m rate=3r/m;
@ -36,10 +36,14 @@ http {
server 127.0.0.1:8081; server 127.0.0.1:8081;
} }
upstream twikoo { upstream wt {
server 127.0.0.1:8082; server 127.0.0.1:8082;
} }
upstream twikoo {
server 127.0.0.1:8083;
}
upstream frp_http_proxy { upstream frp_http_proxy {
server 127.0.0.1:8084; server 127.0.0.1:8084;
} }
@ -56,6 +60,10 @@ http {
server 127.0.0.1:8088; server 127.0.0.1:8088;
} }
upstream meilisearch {
server 127.0.0.1:7700;
}
upstream typesense { upstream typesense {
server 127.0.0.1:8108; server 127.0.0.1:8108;
} }

View File

@ -31,10 +31,18 @@ location ^~ /api/v1/login {
content_by_lua_file lua/login.lua; content_by_lua_file lua/login.lua;
} }
location ^~ /api/v1/search/ {
proxy_pass http://meilisearch/;
}
location ~ ^/api/v1/.*$ { location ~ ^/api/v1/.*$ {
proxy_pass http://local; proxy_pass http://local;
} }
location ~ ^/wt/.+$ {
proxy_pass http://wt;
}
location /freedom { location /freedom {
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404 if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
return 404; return 404;
@ -62,6 +70,7 @@ location ~ ^/(gitea|v2)($|/) {
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
# 这里强制修改 Host 为 gitea.amass.fun 只是为了frpc能够做url路由 # 这里强制修改 Host 为 gitea.amass.fun 只是为了frpc能够做url路由
proxy_set_header Host gitea.amass.fun; proxy_set_header Host gitea.amass.fun;
# proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;

View File

@ -101,7 +101,7 @@ int main(int argc, char const *argv[]) {
auto udpServer = std::make_shared<UdpServer>(application->ioContext()); auto udpServer = std::make_shared<UdpServer>(application->ioContext());
auto mediaServer = std::make_shared<MediaServer>(554, false); auto mediaServer = std::make_shared<MediaServer>(554, false);
auto webApp = Singleton<WebApplication>::instance<Construct>(); auto webApp = Singleton<WebApplication>::instance<Construct>(application->getWtPort());
using namespace boost::asio::ip; using namespace boost::asio::ip;
auto proxyAddress = make_address(application->getServer()); auto proxyAddress = make_address(application->getServer());

View File

@ -12,14 +12,15 @@
#include <Wt/Dbo/SqlConnectionPool.h> #include <Wt/Dbo/SqlConnectionPool.h>
#include <Wt/Dbo/backend/Sqlite3.h> #include <Wt/Dbo/backend/Sqlite3.h>
#include <Wt/WServer.h> #include <Wt/WServer.h>
#include <format>
WebApplication::WebApplication() { WebApplication::WebApplication(uint16_t port) {
try { try {
std::vector<std::string> args; std::vector<std::string> args;
args.push_back("--approot=./build"); args.push_back("--approot=./build");
args.push_back("--docroot=./build"); args.push_back("--docroot=./build");
args.push_back("--config=resources/wt_config.xml"); args.push_back("--config=resources/wt_config.xml");
args.push_back("--http-listen=127.0.0.1:8855"); args.push_back(std::format("--http-listen=127.0.0.1:{}", port));
// --docroot=. --no-compression --http-listen 127.0.0.1:8855 // --docroot=. --no-compression --http-listen 127.0.0.1:8855
initializeAuthenticationService(); initializeAuthenticationService();
@ -27,11 +28,9 @@ WebApplication::WebApplication() {
m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite"); m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite");
m_server->addEntryPoint(Wt::EntryPointType::Application, m_server->addEntryPoint(Wt::EntryPointType::Application,
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false), std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false), "/hello");
"/hello");
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, m_server->addEntryPoint(Wt::EntryPointType::WidgetSet,
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true), std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true), "/wt/app.js");
"/wt/app.js");
m_server->addResource(std::make_shared<AuthenticationResource>(*m_sqlConnectionPool), "/auth"); m_server->addResource(std::make_shared<AuthenticationResource>(*m_sqlConnectionPool), "/auth");
m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext"); m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext");
m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db"); m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db");
@ -45,8 +44,7 @@ WebApplication::WebApplication() {
std::unique_ptr<Wt::Dbo::SqlConnectionPool> WebApplication::createConnectionPool(const std::string &sqlite3) { std::unique_ptr<Wt::Dbo::SqlConnectionPool> WebApplication::createConnectionPool(const std::string &sqlite3) {
auto connection = std::make_unique<Wt::Dbo::backend::Sqlite3>(sqlite3); auto connection = std::make_unique<Wt::Dbo::backend::Sqlite3>(sqlite3);
connection->setProperty("show-queries", "true"); connection->setProperty("show-queries", "true");
connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime, connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime, Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText);
Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText);
return std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), 10); return std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), 10);
} }

View File

@ -31,7 +31,7 @@ public:
const Wt::Auth::PasswordService &passwordService(); const Wt::Auth::PasswordService &passwordService();
protected: protected:
WebApplication(); WebApplication(uint16_t port);
static std::unique_ptr<Wt::Dbo::SqlConnectionPool> createConnectionPool(const std::string &sqlite3); static std::unique_ptr<Wt::Dbo::SqlConnectionPool> createConnectionPool(const std::string &sqlite3);
std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment &env, bool embedded); std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment &env, bool embedded);