我ASP.NET Core APIs
的Linux
. 我有两个environments
- PROD - https://somesite.com - UI 和它的 API 端点 - https://somesite.com/api
- DEV - https://somesite-dev.com - UI 和它的 API 端点 - https://somesite-dev.com/api
两个 UI 都由nginx
on提供服务,port 80 and 443
并且它们各自的 APInginx reverse proxy
用于移植5000
,1880
因为它们.NET Core API
在同一个AWS EC2 instance
现在我有了重新启动这两个.NET Core APIs
- DEV 和 PROD -所需的所有命令rc.local
以下是我的rc.local
内容:
#!/bin/sh
REM This script will be executed *after* all the other init scripts.
REM You can put your own initialization stuff in here if you don't
REM want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
sudo service nginx stop
REM DEV -------------------------------------------
REM Removing previous Error and Output files.
sudo rm /etc/somesite/somesite_dev/Output2.out
sudo rm /etc/somesite/somesite_dev/Error2.err
REM Starting the BG process.
sudo nohup /etc/somesite/somesite_dev/somesite_core_api_dev >
/etc/somesite/somesite_dev/Output2.out 2> /etc/somesite/somesite_dev/Error2.err < /dev/null &
REM Changing Error and Output files permission and Ownership.
sudo chmod 777 /etc/somesite/somesite_dev/Output2.out
sudo chmod 777 /etc/somesite/somesite_dev/Error2.err
sudo chown ec2-user:ec2-user /etc/somesite/somesite_dev/Output2.out
sudo chown ec2-user:ec2-user /etc/somesite/somesite_dev/Error2.err
REM ----------------------------------------------
REM PROD -----------------------------------------
REM Removing previous Error and Output files.
sudo rm /etc/somesite/somesite_prod/Output3.out
sudo rm /etc/somesite/somesite_prod/Error3.err
REM Starting the BG process.
sudo nohup /etc/somesite/somesite_prod/somesite_core_api_prod >
/etc/somesite/somesite_prod/Output3.out 2>
/etc/somesite/somesite_prod/Error3.err < /dev/null &
REM Changing Error and Output files permission and Ownership.
sudo chmod 777 /etc/somesite/somesite_prod/Output3.out
sudo chmod 777 /etc/somesite/somesite_prod/Error3.err
sudo chown ec2-user:ec2-user /etc/somesite/somesite_prod/Output3.out
sudo chown ec2-user:ec2-user /etc/somesite/somesite_prod/Error3.err
REM ----------------------------------------------
REM Force Stoping and Starting nginx
sudo service nginx start
当系统重新启动时,我看到 API 作为 BG 进程运行,但我得到了400 Bad request
但是当我使用文件中的相同命令从终端启动相同的 API 时,即
对于产品 -sudo nohup /etc/somesite/somesite_prod/somesite_core_api_prod > /etc/somesite/somesite_prod/Output3.out 2> /etc/somesite/somesite_prod/Error3.err < /dev/null &
对于开发 -sudo nohup /etc/somesite/somesite_dev/somesite_core_api_dev > /etc/somesite/somesite_dev/Output2.out 2> /etc/somesite/somesite_dev/Error2.err < /dev/null &
我得到的 API 工作正常200
如果有人可以提供帮助,我不确定我在这里缺少什么。
谢谢