Manage multi-django servers for debugging on one pc

来源:互联网 发布:小年糕软件下载 编辑:程序博客网 时间:2024/06/12 01:11

  These days we are developing a demo project to implement our new protocol. As it needs four servers and one client to simulate the evironment to test the protocol, we build the server projects with  the django framework. Since I should test the whole flow first in my own pc, I need to run the four servers in the same time.

  Firstly, I  run the django project with command 'manage.py runserver'. Yeah, the project can be run, but when I entry the url in the browser, it comes out error notes that some modules cannot be found. Strangely, the project works well if using the eclipse to debug or run. The probability  reason, it cannot link the modules which is not located in the same location of 'manag.py' when we start the server with these commands in the terminal.

  Then, I come up with an idea, maybe we can start the server with the commad in the eclipse. Here is the steps. Right click the django project -> Django -> Custom Commad, and input the commad. BTW, the django project with start with the port 8000 by default. If you want to let the project start with different port, please try ' runserver port'. Ok. Now you can start multi-django servers on one pc. Here, you may  encounter the case that you cannot shut down the server. One directly method is using the kill command in the terminal. Command 'ps -A' just list all the processes, but you cannot know which one is the server's. You can check the port with command 'sudo netstat -nap|grep port', then you can find the related process. Finally, just need to use command 'kill processid' to kill the process.