Systemd unit generators unit
systemd.generator(7) - Linux manual page http://man7.org/linux/man-pages/man7/systemd.generator.7.html
SYSTEMD.GENERATOR(7) systemd.generator SYSTEMD.GENERATOR(7)
NAME top
systemd.generator - Systemd unit generators
SYNOPSIS top
/path/to/generator normal-dir early-dir late-dir
/run/systemd/system-generators/*
/etc/systemd/system-generators/*
/usr/local/lib/systemd/system-generators/*
/usr/lib/systemd/system-generators/*
/run/systemd/user-generators/*
/etc/systemd/user-generators/*
/usr/local/lib/systemd/user-generators/*
/usr/lib/systemd/user-generators/*
DESCRIPTION top
Generators are small binaries that live in
/usr/lib/systemd/user-generators/ and other directories listed above.
systemd(1) will execute those binaries very early at bootup and at
configuration reload time — before unit files are loaded. Generators
can dynamically generate unit files or create symbolic links to unit
files to add additional dependencies, thus extending or overriding
existing definitions. Their main purpose is to convert configuration
files that are not native unit files dynamically into native unit
files. Generators are loaded from a set of paths determined during
compilation, as listed above. System and user generators are loaded
from directories with names ending in system-generators/ and
user-generators/, respectively. Generators found in directories
listed earlier override the ones with the same name in directories
lower in the list. A symlink to /dev/null or an empty file can be
used to mask a generator, thereby preventing it from running. Please
note that the order of the two directories with the highest priority
is reversed with respect to the unit load path, and generators in
/run overwrite those in /etc. After installing new generators or updating the configuration,
systemctl daemon-reload may be executed. This will delete the
previous configuration created by generators, re-run all generators,
and cause systemd to reload units from disk. See systemctl(1) for
more information.
WRITING GENERATORS top
Generators are invoked with three arguments: paths to runtime
directories where generators can place their generated unit files or
symlinks. 1. normal-dir argv[1] may be used to override unit files in /usr, but not those
in /etc. This means that unit files placed in this directory take
precedence over vendor unit configuration but not over native
user/administrator unit configuration. 2. early-dir argv[2] may be used to override unit files in /usr and in /etc.
This means that unit files placed in this directory take
precedence over all configuration, both vendor and
user/administrator. 3. late-dir argv[3] may be used to extend the unit file tree without
overriding any other unit files. Any native configuration files
supplied by the vendor or user/administrator take precedence over
the generated ones placed in this directory. Notes
· All generators are executed in parallel. That means all
executables are started at the very same time and need to be able
to cope with this parallelism. · Generators are run very early at boot and cannot rely on any
external services. They may not talk to any other process. That
includes simple things such as logging to syslog(3), or systemd
itself (this means: no systemctl(1))! Non-essential file systems
like /var and /home are mounted after generators have run.
Generators can however rely on the most basic kernel
functionality to be available, including a mounted /sys, /proc,
/dev, /usr. · Units written by generators are removed when the configuration is
reloaded. That means the lifetime of the generated units is
closely bound to the reload cycles of systemd itself. · Generators should only be used to generate unit files, not any
other kind of configuration. Due to the lifecycle logic mentioned
above, generators are not a good fit to generate dynamic
configuration for other services. If you need to generate dynamic
configuration for other services, do so in normal services you
order before the service in question. · Since syslog(3) is not available (see above), log messages have
to be written to /dev/kmsg instead. · It is a good idea to use the SourcePath= directive in generated
unit files to specify the source configuration file you are
generating the unit from. This makes things more easily
understood by the user and also has the benefit that systemd can
warn the user about configuration files that changed on disk but
have not been read yet by systemd. · Generators may write out dynamic unit files or just hook unit
files into other units with the usual .wants/ or .requires/
symlinks. Often, it is nicer to simply instantiate a template
unit file from /usr with a generator instead of writing out
entirely dynamic unit files. Of course, this works only if a
single parameter is to be used. · If you are careful, you can implement generators in shell
scripts. We do recommend C code however, since generators are
executed synchronously and hence delay the entire boot if they
are slow. · Regarding overriding semantics: there are two rules we try to
follow when thinking about the overriding semantics: 1. User configuration should override vendor configuration. This
(mostly) means that stuff from /etc should override stuff
from /usr. 2. Native configuration should override non-native
configuration. This (mostly) means that stuff you generate
should never override native unit files for the same purpose. Of these two rules the first rule is probably the more important
one and breaks the second one sometimes. Hence, when deciding
whether to user argv[1], argv[2], or argv[3], your default choice
should probably be argv[1]. · Instead of heading off now and writing all kind of generators for
legacy configuration file formats, please think twice! It is
often a better idea to just deprecate old stuff instead of
keeping it artificially alive.
EXAMPLES top
Example 1. systemd-fstab-generator
systemd-fstab-generator(8) converts /etc/fstab into native mount
units. It uses argv[1] as location to place the generated unit files
in order to allow the user to override /etc/fstab with her own native
unit files, but also to ensure that /etc/fstab overrides any vendor
default from /usr.
After editing /etc/fstab, the user should invoke systemctl
daemon-reload. This will re-run all generators and cause systemd to
reload units from disk. To actually mount new directories added to
fstab, systemctl start /path/to/mountpoint or systemctl start
local-fs.target may be used.
Example 2. systemd-system-update-generator
systemd-system-update-generator(8) temporarily redirects
default.target to system-update.target, if a system update is
scheduled. Since this needs to override the default user
configuration for default.target, it uses argv[2]. For details about
this logic, see systemd.offline-updates(7).
Example 3. Debugging a generator
dir=$(mktemp -d)
SYSTEMD_LOG_LEVEL=debug /usr/lib/systemd/system-generators/systemd-fstab-generator \
"$dir" "$dir" "$dir"
find $dir
SEE ALSO top
systemd(1), systemd-cryptsetup-generator(8),
systemd-debug-generator(8), systemd-fstab-generator(8), fstab(5),
systemd-getty-generator(8), systemd-gpt-auto-generator(8),
systemd-hibernate-resume-generator(8),
systemd-system-update-generator(8), systemd-sysv-generator(8),
systemd.unit(5), systemctl(1), systemd.environment-generator(7)
COLOPHON top
This page is part of the systemd (systemd system and service manager)
project. Information about the project can be found at
⟨http://www.freedesktop.org/wiki/Software/systemd⟩. If you have a bug
report for this manual page, see
⟨http://www.freedesktop.org/wiki/Software/systemd/#bugreports⟩. This
page was obtained from the project's upstream Git repository
⟨https://github.com/systemd/systemd.git⟩ on 2018-10-29. (At that
time, the date of the most recent commit that was found in the repos‐
itory was 2018-10-29.) If you discover any rendering problems in
this HTML version of the page, or you believe there is a better or
more up-to-date source for the page, or you have corrections or
improvements to the information in this COLOPHON (which is not part
of the original manual page), send a mail to man-pages@man7.org systemd 234 SYSTEMD.GENERATOR(7) unit
[root@d ~]# service mysqd start
Redirecting to /bin/systemctl start mysqd.service
Failed to start mysqd.service: Unit not found.
[root@d ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@d ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-12-21 16:54:24 CST; 15s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 7433 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 7453 (mysqld)
Status: "SERVER_OPERATING"
CGroup: /system.slice/mysqld.service
└─7453 /usr/sbin/mysqld
Dec 21 16:54:22 d systemd[1]: Starting MySQL Server...
Dec 21 16:54:24 d systemd[1]: Started MySQL Server.
[root@d ~]#
Systemd unit generators unit的更多相关文章
- Linux Systemd 详细介绍: Unit、Unit File、Systemctl、Target
Systemd 简介 CentOS 7 使用 Systemd 替换了SysV Ubuntu 从 15.04 开始使用 Systemd Systemd 是 Linux 系统工具,用来启动守护进程,已成为 ...
- [Unit Test] Unit Test Brief Introduction
Levels of Testing- Acceptance- Performance- Functional- Integration- Unit Why Unit Testing- Feedback ...
- linux cron计划任务、chkconfig 命令、systemd命令、unit 相关、target 相关
1.设置说明位置 : cat /etc/crontab # Example of job definition:# .---------------- minute (0 - 59)# | .---- ...
- linux任务计划 chkconfig工具 systemd管理服务 unit介绍 target介绍
linux任务计划 任务计划:特定时间备份数据,重启服务,shell脚本,单独的命令等等. 任务计划配置文件:cat /etc/crontab [root@centos7 ~]# cat /etc/c ...
- [转载]SystemD strikes again : Unit X.mount is bound to inactive unit
http://mamchenkov.net/wordpress/2017/11/09/systemd-strikes-again-unit-var-whatever-mount-is-bound-to ...
- Scala中 => Unit 与 () =>Unit的区别
() => Unit ---> 是一个函数:=> Unit --> 是一个执行结果为Unit的表达式 code: => Unit是 by name 传递参数.参数是一个返 ...
- [Unit Testing] Unit Test a Function that Invokes a Callback with a Sinon Spy
Unit testing functions that invoke callbacks can require a lot of setup code. Using sinon.spy to cre ...
- [Angular + Unit] AngularJS Unit testing using Karma
http://social.technet.microsoft.com/wiki/contents/articles/32300.angularjs-unit-testing-using-karma- ...
- systemd的新特性及常见的systemd unit类型分析
systemd概述 )systemd是一种新的linux系统服务管理器,用于替换init系统,能够管理系统启动过程和系统服务,一旦启动起来,就将监管整个系统.在centos7系统中,PID1被syst ...
随机推荐
- Unity脚本中各函数成员的生命周期
在学习Unity时,掌握如何编写脚本是必须掌握的一项基本技能.但是关于Unity的游戏脚本中各函数的生命周期是怎样开始和结束的,它们的执行顺序是如何安排的?这一点我们要清楚的了解. 我们知道Unity ...
- [mysql] 查询前几条记录
From: http://www.cnblogs.com/xuxm2007/archive/2010/11/16/1878211.html SELECT * FROM table LI ...
- opengl 模板测试 glStencilOp glStencilFunc
下面来设置蒙板缓存和蒙板测试. 首先我们启用蒙板测试,这样就可以修改蒙板缓存中的值. 下面我们来解释蒙板测试函数的含义: 当你使用glEnable(GL_STENCIL_TEST)启用蒙板测试之后,蒙 ...
- 勒布朗法则( LeBlanc)
看<代码整洁之道>看到了一个概念:勒布朗法则. 咦?这个不是NBA中的勒布朗·詹姆斯法则,当然NBA中针对一些球星的Bug表现也制定了一系列的法则,如乔丹法则(乔丹太过于强大).奥尼尔法则 ...
- 记录下DynamicXml和HtmlDocument 使用方式
之前解析都是XmlDocument.Load 而现在可以利用DynamicXml生成Dynamic对象实现强类型操作,很好用. /// <summary> /// 根据Xml路径动态解析成 ...
- foreach使用
1. 读取记录while($row=mysql_fetch_array($result)){$record[]=array( 'title'=>$row['title'], 'body'= ...
- hadoop程序MapReduce之DataDeduplication
需求:去掉文件中重复的数据. 样板:data.log 2016-3-1 a 2016-3-2 b 2016-3-2 c 2016-3-2 b 输出结果: 2016-3-1 a 2016 ...
- lower()
lower() 用于把字符串中的大写字母转换成小写字母 In [1]: str = "Hello World" In [2]: str.lower() Out[2]: 'hello ...
- C语言简介(转自菜鸟教程)
C 简介 C 语言是一种通用的高级语言,最初是由丹尼斯·里奇在贝尔实验室为开发 UNIX 操作系统而设计的.C 语言最开始是于 1972 年在 DEC PDP-11 计算机上被首次实现. 在 1978 ...
- 《C++ Primer Plus》第12章 类和动态内存分配 学习笔记
本章介绍了定义和使用类的许多重要方面.其中的一些方面是非常微妙甚至很难理解的概念.如果其中的某些概念对于您来说过于复杂,也不用害怕——这些问题对于大多数C++的初学者来说都是很难的.通常,对于诸如复制 ...