systemd

Simple C or C++ API for controlling systemd services

时间秒杀一切 提交于 2019-12-08 16:31:55
问题 Goal I'd like to write C/C++ applications and provide an API for them to communicate directly with systemd -managed services. Effectively, I'd like my applications to be able to do the equivalent of systemctl start service_name@unit_number.service without using system() , popen() , or exec() calls ( hard requirement ). Question Is there a simple C/C++ API for communicating with systemd , assuming systemd version 219 (i.e. CentOS v7.4, also a hard requirement )? Work So Far I've scoured online

How can I use spaces in systemd command line arguments?

蹲街弑〆低调 提交于 2019-12-08 15:01:02
问题 I have a systemd unit with spaces in an argument ExecStart=command --argument="text text" It seems that systemd does not recognize the double or single quotes and it splits up the argument into two arguments. Any idea how I can prevent that? I am using systemd v218 within CoreOS. 回答1: This is actually surprisingly difficult to do, unfortunately. I stole this info from this answer. The only way to do it is to put your arguments in an environment file and then use them as variables as such

CentOS 7 设置 svn 开机启动

社会主义新天地 提交于 2019-12-08 13:19:30
安装好 svn 服务后,默认是没有随系统启动自动启动的, CentOS 7 的 /etc/rc.d/rc.local 是没有执行权限的, 系统建议创建 systemd service 启动服务 于是查看 systemd 里 svn 的配置文件 /lib/systemd/system/svnserve.service [Unit] Description=Subversion protocol daemon After=syslog.target network.target [Service] Type=forking EnvironmentFile=/etc/sysconfig/svnserve ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS [Install] WantedBy=multi-user.target 找到 svn 的 service 配置文件 /etc/sysconfig/svnserve 编辑配置文件 vi /etc/sysconfig/svnserve 将 OPTIONS="-r /var/svn" 改为 svn 版本库存放的目录,:wq 保存退出 在提示符下输入 systemctl enable svnserve.service 重启服务器

Beaglebone Boot to Qt App

这一生的挚爱 提交于 2019-12-08 08:25:09
问题 I have searched & googled a lot but I cannot get this to work. I want the Beaglebone to boot up into my Qt application. However, what I get is that the GUI boots up OK but then in a few seconds the Angstrom login screen overwrites my GUI, which stays running in the background. I set up a systemd service as follows in /etc/systemd/system: #!/bin/sh [Unit] Description=Meta Systemd script [Service] USER=root WorkingDirectory=/home/root ExecStart=/bin/sh -c 'source /etc/profile ; /home/root/meta6

Structured logging to journald from within a docker container

旧时模样 提交于 2019-12-08 07:52:37
问题 What is the best way to write structured logs to journald from within a docker container? For example, I have an application that writes using sd_journal_send Rather than change the app, I have tried passing through -v /var/log/systemd/journal:/var/log/systemd/journal It works on the my Ubuntu 16.04 desktop, but not on the CoreOS instances where the app runs (which use the Ubuntu 16.04 base image). I don't quite understand why. Perhaps there is a better way to send to the journal? What

emq 监听1024以下的端口

房东的猫 提交于 2019-12-07 17:42:52
应用程序监听1024以下的端口 我们自己编写的应用程序监听服务端端口号。普通用户只能访问1024以上端口; 当需要使用1024及以下的端口号时,需要应用程序获取root用户权限,操作方法如下(假设我们编写的应用程序名称为 myproc): chown root:root myproc chmod u+s myproc 更改systemctl 是emqx以root用户启动无效 vim /usr/lib/systemd/system/emqx.service [Unit] Description=emqx daemon After=network.target [Service] User=emqx Group=emqx Type=forking Environment=HOME=/var/lib/emqx ExecStart=/bin/sh /usr/bin/emqx start LimitNOFILE=1048576 ExecStop=/bin/sh /usr/bin/emqx stop [Install] WantedBy=multi-user.target 之后发现emqx是个脚本文件不是二进制文件,文件中已经指定了启动用户,所以如果更改启动用户的话需要改这个脚本文件 vim /usr/bin/emqx emq默认是以emqx用户运行的,在命令行启动emqx start

浅析 Linux 初始化 init 系统,第 3 部分: Systemd

倖福魔咒の 提交于 2019-12-07 17:11:18
Systemd 的简介和特点 Systemd 是 Linux 系统中最新的初始化系统(init),它主要的设计目标是克服 sysvinit 固有的缺点,提高系统的启动速度。systemd 和 ubuntu 的 upstart 是竞争对手,预计会取代 UpStart,实际上在作者写作本文时,已经有消息称 Ubuntu 也将采用 systemd 作为其标准的系统初始化系统。 Systemd 的很多概念来源于苹果 Mac OS 操作系统上的 launchd,不过 launchd 专用于苹果系统,因此长期未能获得应有的广泛关注。Systemd 借鉴了很多 launchd 的思想,它的重要特性如下: 同 SysVinit 和 LSB init scripts 兼容 Systemd 是一个"新来的",Linux 上的很多应用程序并没有来得及为它做相应的改变。和 UpStart 一样,systemd 引入了新的配置方式,对应用程序的开发也有一些新的要求。如果 systemd 想替代目前正在运行的初始化系统,就必须和现有程序兼容。任何一个 Linux 发行版都很难为了采用 systemd 而在短时间内将所有的服务代码都修改一遍。 Systemd 提供了和 Sysvinit 以及 LSB initscripts 兼容的特性。系统中已经存在的服务和进程无需修改。这降低了系统向 systemd

Linux服务管理: chkconfig 和 systemctl 命令

只愿长相守 提交于 2019-12-07 17:11:01
对于 Linux 管理员来说这是一个重要(美妙)的话题,所以每个人都必须知道,并练习怎样才能更高效的使用它们。 在 Linux 中,无论何时当你安装任何带有服务和守护进程的包,系统默认会把这些服务的初始化及 systemd 脚本添加进去,不过此时它们并没有被启用。 我们需要手动的开启或者关闭那些服务。Linux 中有三个著名的且一直在被使用的初始化系统。 什么是初始化系统? 在以 Linux/Unix 为基础的操作系统上,init (初始化的简称) 是内核引导系统启动过程中第一个启动的进程。 init 的进程 id (pid)是 1,除非系统关机否则它将会一直在后台运行。 init 首先根据 /etc/inittab 文件决定 Linux 运行的级别,然后根据运行级别在后台启动所有其他进程和应用程序。 BIOS、MBR、GRUB 和内核程序在启动 init 之前就作为 Linux 的引导程序的一部分开始工作了。 下面是 Linux 中可以使用的运行级别(从 0~6 总共七个运行级别): 0:关机 1:单用户模式 2:多用户模式(没有NFS) 3:完全的多用户模式 4:系统未使用 5:图形界面模式 6:重启 下面是 Linux 系统中最常用的三个初始化系统: System V(Sys V) Upstart systemd 什么是 System V(Sys V)? System V

浅析 Linux 初始化 init 系统:sysvinit

邮差的信 提交于 2019-12-07 17:10:38
从 sysvinit 到 systemd 近年来, Linux 系统的 init 进程经历了两次重大的演进,传统的 sysvinit 已经淡出历史舞台,新的 init 系统 UpStart 和 systemd 各有特点,而越来越多的 Linux 发行版采纳了 systemd。本文简要介绍了这三种 init 系统的使用和原理,每个 Linux 系统管理员和系统软件开发者都应该了解它们,以便更好地管理系统和开发应用。本文是系列的第一部分,主要讲述 sysvinit 的特点和使用。 什么是 Init 系统,init 系统的历史和现状 Linux 操作系统 的启动首先从 BIOS 开始,接下来进入 boot loader ,由 bootloader 载入 内核 ,进行 内核初始化 。 内核初始化 的最后一步就是启动 pid 为 1 的 init 进程。这个进程是系统的第一个进程。它负责产生其他所有用户进程。 init 以守护进程方式存在,是所有其他进程的祖先。init 进程非常独特,能够完成其他进程无法完成的任务。 Init 系统能够定义、管理和控制 init 进程的行为。它负责组织和运行许多独立的或相关的始化工作(因此被称为 init 系统),从而让计算机系统进入某种用户预订的运行模式。 仅仅将内核运行起来是毫无实际用途的,必须由 init 系统将系统代入可操作状态。比如启动外壳

pactl called from systemd service always reports “pa_context_connect() failed connection refused”

空扰寡人 提交于 2019-12-07 16:55:32
问题 I've setup a systemd service file to perform some pactl operations at system startup for a test process. While the commands work fine when performed from a terminal I always get "pa_context_connect() failed connection refused" when running the same script from the systemd service by starting the service. I'm also using the 'User=' directive in the service file to ensure that the auto-login user matches the user used to run the service commands. I've read that this is somehow related to the