systemd

Install multiple .service files with dh_systemd packaging

我怕爱的太早我们不能终老 提交于 2020-01-13 05:10:50
问题 I'm currently packaging a python app with dh_virtualenv, to deploy it on Ubuntu 16.04, daemonized with systemd. I use the dh_systemd plugin to automatically install the file my_app.service will install the .deb package, but I'd like to run another process in a different service that schedules tasks for my app, using celery. So, I created another service file, my_app.scheduler.service, but I don't know how to declare this file/app/service in my debian packaging rules, so that while installing

linux知识问答

£可爱£侵袭症+ 提交于 2020-01-13 04:57:43
目录 1. systemd是什么? 2.如何利用systemd, 让自己写的程序运行出错后,可以自动重启 1)在/lib/systemd/system, 下面创建文件,gogs.service 2) 1. systemd是什么? 参考: http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html systemd相对于传统的init, 是操作系统启动的首个进程,然后启动systemd管理的各个服务,d指的是daemon, 守护进程 每个服务,存放在/lib/systemd/system/, 下面,sytemctl enable后,会在/etc/systemd/system/下面创建一个软链接指向这个服务 2.如何利用systemd, 让自己写的程序运行出错后,可以自动重启 1)在/lib/systemd/system, 下面创建文件,gogs.service [Unit] Description=Gogs After=network.target [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get an HTTP error 500 because #

centos7 配置 uwsgi 系统服务(systemd)开机自启

放肆的年华 提交于 2020-01-13 01:56:16
背景生产环境中采用 nginx + uwsgi + django 来部署web服务,这里需要实现uwsgi的启动和停止,简单的处理方式可以直接在命令行中启动和kill掉uwsgi服务,但为了更安全、方便的管理uwsgi服务,配置uwsgi到 systemd 服务中,同时实现开启自启的功能; 另,鉴于 supervisor 不支持 python3 ,没采用supervisor来管理uwsgi服务; 具体配置方法如下: step1. 创建配置文件 /etc/systemd/system/server_uwsgi. service step2. 填入以下内容 [Unit] Description=HTTP Interface Server After=syslog.target [Service] KillSignal=SIGQUIT ExecStart=/usr/bin/uwsgi --ini /path/uwsgi.ini Restart=always Type=notify NotifyAccess=all StandardError=syslog [Install] WantedBy=multi-user.target step3. 将该服务加入到systemd中 systemctl enable /etc/systemd/system/server_uwsgi.service

简单的Dockerfile书写(实例!!!)

懵懂的女人 提交于 2020-01-12 21:17:32
一、Apache mkdir apache cd apache vim Dockerfile #基于的基础镜像 FROM centos #维护镜像的用户信息 MAINTAINER The porject <cloud-ops@centos.org> #镜像操作指令安装apache软件 RUN yum -y update RUN yum -y install httpd #开启80端口 EXPOSE 80 #复制网站首页文件 ADD index.html /var/www/html/index.html #将执行脚本复制到镜像中 ADD run.sh /run.sh RUN chmod 755 /run.sh #启动容器时执行脚本 CMD ["/run.sh"] vim run.sh #!/bin/bash rm -rf /run/httpd/* exec /usr/sbin/apachectl -D FOREGROUND echo "web test" > index.html #生成镜像 docker build -t httpd:centos . #新镜像运行容器 docker run -d -p 1216:80 httpd:centos 二、Mysql 5.7.20 mount.cifs //192.168.142.1/LNMP /mnt cd /mnt cp mysql

开机自启动

柔情痞子 提交于 2020-01-12 06:48:46
查看Systemd版本: systemctl --version 子命令: systemctl reboot //重启 systemd-analyze //查看启动耗时 hostnamectl //查看系统信息 localectl //查看本地化设置 timedatectl //查看时区设置 loginctl //查看当前登录的用户 Unit systemctl list-units //查看当前系统所有Unit systemctl status keepalived.service //查看某个Unit状态 systemctl start/stop keepalived.service //启动/停止服务 默认配置文件路径:/etc/systemd/system/ -> /usr/lib/systemd/system systemctl enable xxx.service //建立符号链接(如果配置文件设置了开机启动,激活开机启动) 配置文件后缀名是Unit的种类:service系统服务、target多个Unit组 systemctl list-unit-files //列出配置文件的状态,enabled已建立启动链接,disabled未建立启动链接,static配置文件无Install部分,无法执行,只能作为其他配置文件的依赖,masked禁止建立启动链接 systemctl

How to restart a service if its dependent service is restarted

冷暖自知 提交于 2020-01-12 06:27:44
问题 A service (say bar.service) is dependent on another service (say foo.service), like below bar's service file: [Unit] After=foo.service Requires=foo.service ... If foo.service is restarted (either manually or due to a bug), how can bar.service be automatically restarted as well? 回答1: You can use PartOf . [Unit] After=foo.service Requires=foo.service PartOf=foo.service From the systemd.unit man page: PartOf= Configures dependencies similar to Requires=, but limited to stopping and restarting of

How to restart a service if its dependent service is restarted

安稳与你 提交于 2020-01-12 06:27:08
问题 A service (say bar.service) is dependent on another service (say foo.service), like below bar's service file: [Unit] After=foo.service Requires=foo.service ... If foo.service is restarted (either manually or due to a bug), how can bar.service be automatically restarted as well? 回答1: You can use PartOf . [Unit] After=foo.service Requires=foo.service PartOf=foo.service From the systemd.unit man page: PartOf= Configures dependencies similar to Requires=, but limited to stopping and restarting of

nginx:如何用systemctl命令管理nginx的开关?(3)

左心房为你撑大大i 提交于 2020-01-12 04:25:53
在之前的nginx的开启与关闭都是通过脚本。现在做个systemctl 命令去控制nginx。 步骤一:下载httpd 服务 目的是想用它所谓配置文件模板,yum install httpd -y 步骤二:复制服务模板文件到/etc/systemed/system/ / usr / lib / systemd / system #里面有各种服务 cp httpd . service / etc / systemd / system / nginx . service #自定义的服务一般都放在/etc/systemd/system目录里 步骤三:修改配置文件,vim nginx.service 原来的: 修改之后: 步骤四:用systemctl 命令开启服务 注意: 如果之前用脚本开启了nginx,那么就得用脚本方式关闭,再用systemctl 命令开启,用啥方式开启就得用啥方式关闭,有始有终。 来源: CSDN 作者: sll2021 链接: https://blog.csdn.net/qq_41977453/article/details/103746728

Unable to start postgresql.service?

北城余情 提交于 2020-01-12 03:40:35
问题 I'm using arch linux (4.8.13-1-ARCH). I'm trying to set up PostgreSQL as instructed here. After performing [postgres@BitBox ~]$ initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data' The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on

适合最新版docker自定义启动配置

蹲街弑〆低调 提交于 2020-01-11 21:01:35
docker不断发布新版本,以前默认的在 /etc/default/docker里修改,但是新版已经不推荐了 注意: 一些文章推荐在 /lib/systemd/system/docker.service 文见上修改配置 但是官方建议如下 /usr/lib/systemd/system or /lib/systemd/system 包含默认配置.建议不要修改 我们手动建立配置文件 $ sudo mkdir /etc/systemd/system/docker.service.d $ sudo touch /etc/systemd/system/docker.service.d/docker.conf $ sudo vi /etc/systemd/system/docker.service.d/docker.conf 添加内容 [Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// 然后重新读取验证 $ sudo systemctl daemon-reload $ sudo systemctl restart docker Verify docker daemon is running 以上就是我们新建的配置文件 如果你想使用 /etc/default/docker文件配置你的docker 在 /etc