English 中文(简体)
django开发服务器,在运行背景时如何停止使用?
原标题:django development server, how to stop it when it run in background?

我使用云层服务器测试我的django。 小型项目,如<条码>manage.pyprserver,然后我 out掉我的云层服务器,但当我重载我的云服务器时,我不知道如何阻止发展服务器,我不得不杀死这一进程以阻止其发展?

最佳回答

The answer is findable via Google -- and answered in other forums. Example solution is available on the Unix & Linux StackExchange site.

为了明确起见,您可以:

ps auxw | grep runserver

这将恢复这一进程及其各自的项目信息数据库,例如:

de        7956  1.8  0.6 540204 55212 ?        Sl   13:27   0:09 /home/de/Development/sampleproject/bin/python ./manage.py runserver

在这一特定情况下,项目信息数据库为7956。 现在,这是为了制止:

kill 7956

为了明确/处理其中的一些评论,你必须这样做,因为你在背景(<代码>&在你指挥下)重新运行发展服务器。 为什么没有“建造”Django停止选择。

问题回答

One liner..

pkill -f runserver

Try this

lsof -t -i tcp:8000 | xargs kill -9

Ctrl+c应当发挥作用。 如果是Ctrl+/,就会强行杀害这一进程。

看来,这只是一个诱兆,即django公司为停止发展服务器提供指挥。 我认为,它以前有过。

我们可以使用以下指挥。

- 设计;

然后,我们将获得一些与项目信息数据库运行的进程,找到我们的假日服务器项目信息数据库和杀案程序。

- &;杀人;9 PID

For example:
enter image description here

As far as i know ctrl+c or kill process is only ways to do that on remote machine. If you will use Gunicorn server or somethink similar you will be able to do that using Supervisor.

这对我来说是窗户。

利用以下指挥系统列出所有联系和倾听港口(-a)及其项目信息数据库(-o)。

netstat -a -o

https://i.stack.imgur.com/OophC.png”rel=“nofollow noreferer”> Find the PID of the process

然后利用这一手段来杀害这一进程。

taskkill /PID PUT_THE_PID_HERE /F

From task manager you can end the python tasks that are running. Now run python manage.py runserver from your project directory and it will work.

视窗:

@ECHO OFF
SET /A port=8000
FOR /F "tokens=5" %%T IN ( netstat -ano ^| findstr :%port% ) DO (
    SET /A processid=%%T
    TASKKILL /PID %%T /F
)

发放

<编码> SUCCESS:与PID 5104有关的程序已经终止。

您可以在当地环境中使用服务器

CTRL+SHIFT+C





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签