【问题标题】:System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down系统尚未使用 systemd 作为 init system (PID 1) 引导。不能操作。无法连接到总线:主机已关闭
【发布时间】:2021-07-14 13:26:01
【问题描述】:

我正在尝试在谷歌云终端中使用以下命令创建 systemd 服务后激活服务:

vim /etc/systemd/system/app.service

将以下内容粘贴到此文件中:

#vim /etc/systemd/system/app.service
[Unit]
#  specifies metadata and dependencies
Description=Gunicorn instance to serve myproject
After=network.target
# tells the init system to only start this after the networking target has been reached
# We will give our regular user account ownership of the process since it owns all of the relevant files
[Service]
# Service specify the user and group under which our process will run.
User=clashgamers2021
# give group ownership to the www-data group so that Nginx can communicate easily with the Gunicorn processes.
Group=www-data
# We'll then map out the working directory and set the PATH environmental variable so that the init system knows where our the executables for the process are located (wi$
WorkingDirectory=/home/clashgamers2021/clashgamers/
Environment="PATH=/home/clashgamers2021/clashgamers/env/bin"
# We'll then specify the commanded to start the service
ExecStart=/home/clashgamers2021/clashgamers/env/bin/gunicorn --workers 3 --bind unix:app.sock -m 007 wsgi:app
# This will tell systemd what to link this service to if we enable it to start at boot. We want this service to start when the regular multi-user system is up and running:
[Install]
WantedBy=multi-user.target

为了激活这项服务,我输入了:

sudo systemctl start app
sudo systemctl enable app

但是我得到了这个错误:

clashgamers2021@cloudshell:~/clashgamers (clash-gamers-318206)$ sudo systemctl start app
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

【问题讨论】:

  • 您好!您提到您在google cloud terminal 中运行此代码,具体在哪里?在虚拟机内部还是在 Google Cloud Shell 内部?您正在使用什么操作系统(Red Hat、Rocky、COS 等)运行什么类型的 VM(N1、E2 等)?
  • 根据错误信息,您确定您的操作系统版本安装了systemd服务吗?确认第一件事是我在您的原始帖子中没有看到您,请确保在添加新服务后重新加载 systemd 守护进程:systemctl daemon-reload

标签: google-cloud-platform systemd


【解决方案1】:

您正在尝试运行Cloud Shell 中的命令:

Cloud Shell 是 Google Cloud 的交互式 shell 环境,可让您轻松学习和试验 Google Cloud,并通过网络浏览器管理您的项目和资源。

Create a new VM(指定硬件和操作系统)并在 Cloud Console 中使用 SSH button 或使用文档中描述的其他方法连接到它。

然后运行您的命令,如果它们不起作用,请使用更多详细信息更新您的问题。

【讨论】:

猜你喜欢
  • 2019-02-11
  • 1970-01-01
  • 2021-04-16
  • 2021-04-12
  • 2019-07-25
  • 1970-01-01
  • 1970-01-01
  • 2020-04-15
  • 1970-01-01
相关资源
最近更新 更多