简体   繁体   English

如何在AWS中同时运行两个命令行?

[英]How do i run two command lines in AWS simultaneously?

I have a Django app that I am trying to deploy to AWS. 我有一个Django应用程序,我正在尝试部署到AWS。 I need two command lines to run the app. 我需要两个命令行来运行应用程序。 One command line will be used to runserver and another one to run a background task. 一个命令行将用于runserver,另一个命令行用于运行后台任务。 That is how the app runs in my localserver. 这就是应用程序在我的本地服务器中运行的方式。

How do I start two command lines in AWS? 如何在AWS中启动两个命令行?

As i can understand your django app is currently in development mode, I've used tmux for development mode, this page will guide you better to use tmux. 我可以理解您的django应用程序目前处于开发模式,我已经将tmux用于开发模式,此页面将指导您更好地使用tmux。 Once you have started a tmux session run python3 manage.py runserver and then detach to the session using ctrl-b then press d and now your app will run even after you exit the shell. 启动tmux会话后,运行python3 manage.py runserver ,然后使用ctrl-b分离到会话,然后按d ,现在即使退出shell,您的应用程序也会运行。
To know more about tmux go through this page . 要了解有关tmux的更多信息,请浏览此页面

In case you have to run your app in production mode Don't use above method, run your app with any of nginx or apache2 server. 如果您必须在生产模式下运行您的应用程序不要使用上述方法,请使用任何nginxapache2服务器运行您的应用程序。 This tutorial can guide you to set up your django app with nginx and gunicorn. 本教程可以指导您使用nginx和gunicorn设置django应用程序。

Supervisor is a good way to control that. 主管是控制它的好方法。 You can run a lot of processes (like server, migration, collectstatic, Celery) easily. 您可以轻松地运行许多流程(如服务器,迁移,collectstatic,Celery)。
Additionally, you can ensure that all processes will run again when your machine reboots. 此外,您可以确保在计算机重新启动时所有进程都会再次运行。
And, as everybody said, you have to install a server in production that supports WSGI in order to run Django properly. 并且,正如大家所说,你必须在生产中安装支持WSGI的服务器才能正确运行Django。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何基于子域运行两个单独的Django网站? - How do I run two separate Django sites based on a subdomain? 如何同时打印两个列表? - How to print two list simultaneously? 如何设置 cronjob 以在 AWS 弹性 beanstalk 中运行 Django 管理命令 - How to set a cronjob to run a Django management command in AWS elastic beanstalk 当可能有多个实例时,如何确保 crontab 命令在 AWS 上运行一次? - How do I ensure crontab commands run once on AWS when there may be multiple instances? 加载环境var时,如何以cron身份运行python命令? - How do I run my python command as a cron while loading my environment vars? Django和Celery:如何使用Celery安排一次作业只运行一次(类似于linux中的“at”命令)? - Django & Celery: How do I schedule a job to run only once using Celery(similar to “at” command in linux)? 如何在新的 Eclipse/Pydev 运行配置中使用 Django 命令扩展 - How do I use Django Command Extensions with a new Eclipse/Pydev run configuration 如何同时运行xmpp进程和Django服务器 - how to run a xmpp process and django server simultaneously RabbitMQ:防止作业在两个不同的工人上同时运行 - RabbitMQ: Preventing jobs to run simultaneously on two different workers 如何使两个模型同时出现在Django主页上? - How can I make two models appear on my Django homepage simultaneously?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM