[英]How can i start a django server and npm start in one bash script?
As my first batch script, I want to run my backend and frontend with just one script.作为我的第一个批处理脚本,我想只用一个脚本运行我的后端和前端。 My backend is in python with Django and my frontend is in react.我的后端在 python 和 Django 中,我的前端正在反应。 I, therefore, have to processes I need to run.因此,我必须运行我需要运行的进程。 But I don't know how to run them in parallel as I need to start a virtual environment in python first.但我不知道如何并行运行它们,因为我需要先在 python 中启动一个虚拟环境。
I don't understand how it would log the server logs.我不明白它将如何记录服务器日志。 Is there an option to make two terminal windows or a new terminal tab?是否可以选择制作两个端子 windows 或新的端子标签? Or would it log in to one terminal together?还是一起登录一个终端?
#!/bin/bash
DJANGODIR=/Users/usr/Desktop/programming/app/django
REACTDIR=/Users/urs/Desktop/programming/app/react
# START REACT FRONTEND
echo Starting React Server
# Option 1
# cd $REACTDIR
# npm start
# Option 2
# start app from any directory without cd into it
# npm --prefix $REACTDIR run start
# START DJANGO BACKEND
echo Starting Django Server
# cd $DJANGODIR
# Start virtual environment
# source venv/bin/activate
# Start Server
# python3 manage.py runserver
# Activating and running in one command
# source venv/bin/activate python3 manage.py runserver
# Here is where I'm not knowing how to run them in parallel
source venv/bin/activate python3 manage.py runserver & npm --prefix $REACTDIR run start
Have you tried with the pipe operator?您是否尝试过 pipe 运算符? Pipe operator explained Pipe 算子解释
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.