引擎国产化适配&重构笔记
Posted mb61737bf531aa2
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了引擎国产化适配&重构笔记相关的知识,希望对你有一定的参考价值。
关于守护进程dup stderr问题;
fd = open("/dev/null", O_RDWR);
if (dup2(fd, STDIN_FILENO) == -1)
if (dup2(fd, STDOUT_FILENO) == -1)
#if xxx
if (dup2(fd, STDERR_FILENO) == -1)
#else
fd_log = open("pathlog", O_RDWR);
if (dup2(fd_log, STDERR_FILENO) == -1)
#endif
if (fd > STDERR_FILENO)
将dup2(fd_log, stderr)还是dup2(fd_null, stderr);
也就是标准错误重定向到 黑洞还是 log文件中
看下man dup的结果:dup2() makes newfd be the copy of oldfd, closing newfd first if necessary,
NAME
dup, dup2, dup3 - duplicate a file descriptor
SYNOPSIS
#include <unistd.h>
int dup(int oldfd);
int dup2(int oldfd, int newfd);
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h> /* Obtain O_* constant definitions */
#include <unistd.h>
int dup3(int oldfd, int newfd, int flags);
DESCRIPTION
These system calls create a copy of the file descriptor oldfd.
dup() uses the lowest-numbered unused descriptor for the new descriptor.
dup2() makes newfd be the copy of oldfd, closing newfd first if necessary, but note the following:
* If oldfd is not a valid file descriptor, then the call fails, and newfd is not closed.
* If oldfd is a valid file descriptor, and newfd has the same value as oldfd, then dup2() does nothing, and returns newfd.
After a successful return from one of these system calls, the old and new file descriptors may be used interchangeably. They refer to the same open file description (see open(2)) and thus share file offset and file status flags; for
example, if the file offset is modified by using lseek(2) on one of the descriptors, the offset is also changed for the other.
The two descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor is off.
dup3() is the same as dup2(), except that:
* The caller can force the close-on-exec flag to be set for the new file descriptor by specifying O_CLOEXEC in flags. See the description of the same flag in open(2) for reasons why this may be useful.
* If oldfd equals newfd, then dup3() fails with the error EINVAL.
引擎注意事项:
- 进程名称
- cpu绑定
- 进程资源设置(file_limit core_limit signal_mask)
- 时间戳的设置 (多进程/多线程 )volatile 防止优化
- 守护进程
- 信号处理 以及 coredump处理
- log设置
- 参数处理
- 进程唯一实例
- 去掉root 特权
- 进程间通信-socketpair pipe unix-socket 共享内存(mmap munmap以及shmget shmat shmctl)共享内存blogpipe-unix blog
网络中间件 :
采用 libevent libuv 再次封装还是 结合自己业务再次编写?
协议解析:
打包问题:
- fakeroot权限:使用fakeroot模拟root权限执行程序,在打包的时候,包里面的文件所有者必须是root。必须以root 权限来执行打包命令,但是应该避免在制作包的时候使用root权限。 为了解决这个矛盾,fakeroot被开发出来了。在fakeroot环境中,操作文件就像使用root操作文件一样,但是,实际上系统中文件的权限还是原来的权限。
LD_PRELOAD=//usr/userpath/x86build/lib/libfakeroot.so python build_packet.py
http代理服务器(3-4-7层代理)-网络事件库公共组件、内核kernel驱动 摄像头驱动 tcpip网络协议栈、netfilter、bridge 好像看过!!!!
但行好事 莫问前程
--身高体重180的胖子
以上是关于引擎国产化适配&重构笔记的主要内容,如果未能解决你的问题,请参考以下文章
大数据运维 docker搭建图数据库nebula适配国产化服务器