Ubuntu Upstart初始化脚本无法运行:启动myproject提示未知任务
Hey there, let's break down why you're hitting that error and how to fix it. The start command you're using is part of Upstart—an older init system that's been replaced by systemd on most modern Linux distributions (including recent versions of Amazon Linux, Ubuntu, and RHEL).
First, confirm which init system your EC2 instance is running:
ps --no-headers -o comm 1
If the output is systemd, that's the culprit—your system doesn't use Upstart, so it doesn't recognize the job file you created in /etc/init/.
Here's how to switch to a systemd service file:
Remove the old Upstart file (optional, but avoids confusion later):
sudo rm /etc/init/myproject.confCreate a systemd service file at
/etc/systemd/system/myproject.servicewith the following content (it mirrors your original Upstart config but uses systemd's syntax):[Unit] Description=uWSGI server instance configured to serve myproject After=network.target # Ensures the service starts after the network is up [Service] User=ec2-user Group=www-data Environment="PATH=/home/ec2-user/login_test/venv/bin" WorkingDirectory=/home/ec2-user/login_test/oauth_login # Use absolute path to uWSGI to avoid environment issues ExecStart=/home/ec2-user/login_test/venv/bin/uwsgi --ini wsgi.ini [Install] WantedBy=multi-user.target # Starts the service in runlevels 2-5Reload systemd to recognize the new service:
sudo systemctl daemon-reloadStart your service:
sudo systemctl start myproject(Optional) Set it to start on boot:
sudo systemctl enable myproject
You can check the service status anytime with:
sudo systemctl status myproject
内容的提问来源于stack exchange,提问作者sol-invictii

