blog
April 22, 2022
select가 readable이라고 판단하는 경우는
Asynchronous blocking I/O
동기(Synchronous)는 정확히 무엇을 의미하는걸까?
Blocking-NonBlocking-Synchronous-Asynchronous
int main(configuration file)
check validity of configuration file
Beginner’s Guide
directive = simple-directive / block-directive
simple-directive = name SPACES *parameter ";"
block-directive = name SPACES *parameter "{" *instruction "}"
context = name SPACES *parameter "{" *(instruction / directive) "}"
main {
events {}
http {}
}
http {
server {}
}
server {
location {}
}
location / {
root /data/www;
}
server {
location / {
root /data/www;
}
location /images/ {
root /data;
}
}
server {
listen 8080;
root /data/upl;
location / {
}
}
server {
location ~ .php$ {
root /data
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
root@2fef7e25b01f:/etc/nginx/sites-available# nginx -s reload
nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:74
root@2fef7e25b01f:/etc/nginx/sites-available#
1. configuration file을 파싱해서 메모리에 구조화하여 저장한다.
단순 문법적 오류에 대해 에러를 발생시킨다. ( ex: "{}"를 사용하기로 약속했다면 여는 괄호와 닫는 괄호가 짝이 맞는가? )
일단 전부 string으로 값을 읽어온다.
2. 여러 방식으로 에러 check를 진행한다.
1. directive가 올바른가? ( ex: 구현하지 않은 directive )
2. directive의 인자가 올바른가? ( ex: checkListen(), checkIndex() )
- directive에 따라 인자의 type, 인자의 범위, 인자의 갯수 등 확인
3. 파싱해온 값으로 server의 변수들을 설정한다.
for (fin >> string) {
if (string is syntax error)
handle error;
else
parser.add(string);
}
try {
server.setWithParser(parser);
}
catch (server set error) {
handle error;
}