Added thread_num
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
//#define MULTI_THREAD
|
//#define MULTI_THREAD
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
//#define DEBUG_PACKET
|
//#define DEBUG_PACKET
|
||||||
|
//#define THREAD_NUM
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
boost::asio::io_service *ios_loop = nullptr;
|
boost::asio::io_service *ios_loop = nullptr;
|
||||||
@@ -459,7 +459,11 @@ int main(int argc, char* argv[])
|
|||||||
acceptor.accept_connections();
|
acceptor.accept_connections();
|
||||||
#ifdef MULTI_THREAD
|
#ifdef MULTI_THREAD
|
||||||
boost::thread_group tg;
|
boost::thread_group tg;
|
||||||
|
#ifdef THREAD_NUM
|
||||||
|
for (unsigned i = 0; i < THREAD_NUM; ++i)
|
||||||
|
#else
|
||||||
for (unsigned i = 0; i < thread::hardware_concurrency(); ++i)
|
for (unsigned i = 0; i < thread::hardware_concurrency(); ++i)
|
||||||
|
#endif
|
||||||
tg.create_thread(boost::bind(&boost::asio::io_service::run, &ios));
|
tg.create_thread(boost::bind(&boost::asio::io_service::run, &ios));
|
||||||
|
|
||||||
tg.join_all();
|
tg.join_all();
|
||||||
|
|||||||
8
start.py
8
start.py
@@ -23,6 +23,8 @@ parser = argparse.ArgumentParser()
|
|||||||
parser.add_argument('--port', "-p", type=int, required=False, help='Port where open the web service of the firewall', default=4444)
|
parser.add_argument('--port', "-p", type=int, required=False, help='Port where open the web service of the firewall', default=4444)
|
||||||
parser.add_argument('--no-autostart', "-n", required=False, action="store_true", help='Auto-execute "docker-compose up -d --build"', default=False)
|
parser.add_argument('--no-autostart', "-n", required=False, action="store_true", help='Auto-execute "docker-compose up -d --build"', default=False)
|
||||||
parser.add_argument('--single-thread', "-s", required=False, action="store_true", help='Disable multi-threaded proxy"', default=False)
|
parser.add_argument('--single-thread', "-s", required=False, action="store_true", help='Disable multi-threaded proxy"', default=False)
|
||||||
|
parser.add_argument('--thread-num', "-t", type=int, required=False, help='Number of threads to use', default=None)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
sep()
|
sep()
|
||||||
puts(f"Firegex", color=colors.yellow, end="")
|
puts(f"Firegex", color=colors.yellow, end="")
|
||||||
@@ -31,6 +33,8 @@ puts(f"{args.port}", color=colors.cyan)
|
|||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
|
gcc_params = "-D MULTI_THREAD" if not args.single_thread else ""
|
||||||
|
gcc_params+= f" -D THREAD_NUM={args.thread_num}" if args.thread_num else ""
|
||||||
with open("docker-compose.yml","wt") as compose:
|
with open("docker-compose.yml","wt") as compose:
|
||||||
|
|
||||||
if "linux" in sys.platform and not 'microsoft-standard' in platform.uname().release: #Check if not is a wsl also
|
if "linux" in sys.platform and not 'microsoft-standard' in platform.uname().release: #Check if not is a wsl also
|
||||||
@@ -43,7 +47,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
- GCC_PARAMS={"-D MULTI_THREAD" if not args.single_thread else ""}
|
- GCC_PARAMS={gcc_params}
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
environment:
|
environment:
|
||||||
- NGINX_PORT={args.port}
|
- NGINX_PORT={args.port}
|
||||||
@@ -64,7 +68,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
- GCC_PARAMS={"-D MULTI_THREAD" if not args.single_thread else ""}
|
- GCC_PARAMS={gcc_params}
|
||||||
ports:
|
ports:
|
||||||
- {args.port}:{args.port}
|
- {args.port}:{args.port}
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user