You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu Upstart初始化脚本无法运行:启动myproject提示未知任务

Fixing "start: Unknown job: myproject" Error

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:

  1. Remove the old Upstart file (optional, but avoids confusion later):

    sudo rm /etc/init/myproject.conf
    
  2. Create a systemd service file at /etc/systemd/system/myproject.service with 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-5
    
  3. Reload systemd to recognize the new service:

    sudo systemctl daemon-reload
    
  4. Start your service:

    sudo systemctl start myproject
    
  5. (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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:57:55