์ง๊ธ์ ๋ค์๊ณผ ๊ฐ์ด ์น ์ฑ์ ์์ํฉ๋๋ค.
$ gunicorn webapp:application
webapp.py ๋ด๋ถ์ ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ฅ์ ์ผ๋ถ ๋งค๊ฐ๋ณ์๋ฅผ ์ ๊ณตํ๊ณ ์ถ์ต๋๋ค. ํนํ ๊ตฌ์ฑ ํ์ผ์ ์ฌ์ฉํ์ฌ ์น ์ฑ์ด ์๋ํ๋ ๋ฐฉ์์ ์กฐ์ ํ๊ณ ์ถ์ต๋๋ค.
๊ตฌ์ฑ ํ์ผ๋ก gunicorn์ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ ๋ํ ๋ฌธ์๋ฅผ ์ฝ์์ง๋ง ์ํ์ง ์์ต๋๋ค.
๋๋ ์ด๊ฒ์ ์๋ํ๊ณ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
$ gunicorn webapp:application dev.cfg
๋ด๊ฐ ๋งํ ์ ์๋ ํ gunicorn์ "application dev.cfg"๋ผ๋ ์ด๋ฆ์ ์ฝ๋ฌ๋ธ์ ์ฐพ์ผ๋ ค๊ณ ํ์ต๋๋ค.
์ด๋ค ์์ด๋์ด?
์ ํ๋ฆฌ์ผ์ด์ ๋ชจ๋์์ ๋ค์๊ณผ ๊ฐ์ด ํ ์ ์์ต๋๋ค.
def load_app(cfg_file):
cfg = load_app_config(cfg_file)
return my_app(cfg)
๊ทธ๋ฐ ๋ค์ ๋ค์๊ณผ ๊ฐ์ด ์ฑ์ ์์ํฉ๋๋ค.
$ gunicorn 'webapp:load_app("/path/to/my_config.ini")'
๋๋ตํ๋ค.
@benoitc ๋ช ๋ ์ด
@pellunutty ์ง๊ธ์ ์ ๋ต์ด ์๋๋ผ๊ณ ์๊ฐํฉ๋๋ค. ์ ํ๋ฆฌ์ผ์ด์
ํด๋์ค(์: BaseApplication
) ์ค ํ๋๋ฅผ ํ์ ํด๋์ค๋ก ๋ถ๋ฅํ๊ณ load_config
๋ฉ์๋์์ ๊ด๋ จ ์ ๋ณด๋ฅผ ๊ตฌ๋ฌธ ๋ถ์ํ ์ ์์ต๋๋ค. ์์ ๋ http://docs.gunicorn.org/en/stable/custom.html ์ ์ฐธ์กฐ
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ ํ๋ฆฌ์ผ์ด์ ๋ชจ๋์์ ๋ค์๊ณผ ๊ฐ์ด ํ ์ ์์ต๋๋ค.
๊ทธ๋ฐ ๋ค์ ๋ค์๊ณผ ๊ฐ์ด ์ฑ์ ์์ํฉ๋๋ค.