bug: when modify config file apisix shoud check config file
Issue description
Environment
- apisix version (cmd:
apisix version): apisix 2.1 - OS: (cmd:
uname -a) centos 7.6 - OpenResty / Nginx version: (cmd:
nginx -Voropenresty -V)
Minimal test code / Steps to reproduce the issue
- when apisix running and modify config file ,when config file error apisix restart fail ,service down
- apisix should check modify config file , example nginx -t , avoid error 3.
What's the actual result? (including assertion message & call stack if applicable)
What's the expected result?
Thank you very much for your report, we need to determine this issue. It would be better if you could provide a recurring use case of a problem.
if apisix config file errory when apisix restart or apisix reload appear error
example:
when modify config file apper errory so easy config file yaml format error
It is strongly recommended to add configuration file verification to restart or reload the configuration file
better with cli example apisix check config ,return configuration file is ok, aviod restart fail
example: cat /usr/local/apisix/conf/config.yaml | tail -3 # the default value is true, e.g. the certificate will be verified strictly.
test file error
123 apisix restart lua: /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:641: failed to classify line: 123 stack traceback: [C]: in function 'error' /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:641: in function 'parsemap' /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:735: in function 'parsedocuments' /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:760: in function 'parse' /usr/share/lua/5.1/apisix/cli/file.lua:132: in function 'read_yaml_conf' /usr/bin/apisix:156: in function 'init' /usr/bin/apisix:363: in function 'start' /usr/bin/apisix:377: in function '?' /usr/bin/apisix:418: in main chunk [C]: ? aviod apisix restart fali, service fail
Yes, the output is no so friendly. @Yangzcy423911 Would you like to submit a PR to optimize the interaction when configuration file is malformed, thanks!
welcome PR to fix this issue
shouldn't test usage added to apisix help? as of 2.12.1 it's not there
shouldn't
testusage added toapisix help? as of 2.12.1 it's not there
test usage has been released as of 2.11.0. If this is not your verification result, you can submit a new issue.
i mean, i didn't know it exists:
/opt/apisix> docker-compose exec apisix apisix help
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua help
Usage: apisix [action] <argument>
help: show this message, then exit
init: initialize the local nginx.conf
init_etcd: initialize the data of etcd
start: start the apisix server
stop: stop the apisix server
quit: stop the apisix server gracefully
restart: restart the apisix server
reload: reload the apisix server
version: print the version of apisix
i mean, i didn't know it exists:
maybe we need to add test to apisix help? cc @spacewander @nic-chen
i mean, i didn't know it exists:
maybe we need to add
testtoapisix help? cc @spacewander @nic-chen
It's usefult. Just like nginx -t.
i mean, i didn't know it exists:
maybe we need to add
testtoapisix help? cc @spacewander @nic-chen
+1
add apisix test to apisix help, people could know this command quickly.
@apit welcome to submit a PR to make it done. : )
Let's move the discussion to https://github.com/apache/apisix/issues/7148 as this validation is already done.