Articles of systemd

Nginxlogin到stderr

我想将nginx访问日志redirect到stdout ,以便能够通过journalctl (systemd)分析它们。 核准答案有同样的问题。 有nginx的access_log和error_log日志到STDOUT和主进程的STDERR但它不适合我。 用/dev/stderr我open() "/dev/stderr" failed (6: No such device or address) 。 使用/dev/stdout我在journalctl -u nginx没有访问日志。 nginx.conf daemon off; http { access_log /dev/stdout; error_log /dev/stdout; … } … sitename.conf server { server_name sitename.com; root /home/username/sitename.com; location / { proxy_pass http://localhost:3000/; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log on; } } nginx.service [Service] Type=forking […]

Fedora 20 systemctl nginx权限被拒绝

我已经在Windows 7上的VMware Workstation中安装了fedora 20。一切顺利,直到我通过yum install nginx来yum install nginx 。 编辑nginx.conf(只更改位置/根目录) location / { root /mnt/hgfs/www; index index.html index.htm; } 我尝试通过systemctl start nginx 。 Nginx处于活动状态,但无法访问根文件夹。 日志说13: Permission denied 。 我相信nginx有权限访问该文件夹。 起初,我认为这可能是因为HGFS。 我把根改成了/usr/share/nginx/html ,而不是问题解决了。 但我不会使用这个文件夹作为我的根。 所以我通过mount /dev/sdb1 /www (格式化为ext4)挂载新磁盘,设置777并更改nginx.conf。 然后问题再次显示。 我指定systemctl的原因是我试图通过sudo nginx运行sudo nginx 。 任何事情都很完美,没有错误出现。 systemctl有不同的文件系统的问题? 但sdb1与原始文件系统的格式相同。 我能做些什么来解决这个问题?

systemd无法为Tomcat启动定制服务

我有一个简单的系统服务,我已经创build正确启动。 这里是tomcat.service,我已经放入/lib/systemd/system : [Unit] Description=A systemd daemon configured to run Apache Tomcat 8. After=syslog.target network.target [Service] Type=forking PIDFile=/home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/tomcat.pid ExecStart=/home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/startup.sh ExecStop=/home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/shutdown.sh [Install] WantedBy=multi-user.target 将文件放入文件夹后,我运行systemctl enable tomcat.service 。 在这之后,运行sudo systemctl start tomcat.service会给我下面的错误: Job for tomcat.service failed. See 'systemctl status tomcat.service' and 'journalctl -xn' for details. […]

为什么我的脚本启动UWSGI不能在启动时运行?

我想知道你能否帮忙 我正在运行以下版本: OS: SMP Debian 3.2.81-1 x86_64 uWSGI: uWSGI 2.0.11.2 我手动安装了uWSGI,因为我想使用特定的版本。 使用以下命令: – apt-get install build-essential psmisc python-dev libxml2 libxml2-dev python-setuptools cd /opt/ wget http://projects.unbit.it/downloads/uwsgi-2.0.11.2.tar.gz tar -zxvf uwsgi-2.0.11.2.tar.gz mv uwsgi-2.0.11.2/ uwsgi/ cd uwsgi/ python setup.py install 我试图在另一台服务器上复制项目已经在实际环境中工作的设置(我基本上设置了一个testing服务器环境)。 原始服务器启动时运行uWSGI。 为了弄清楚这是怎么发生的,我用了 htops 我已经能够通过一组命令行开关来识别uWSGI是否在现有的服务器上运行。 我已经设法追踪了在init.d文件夹中用这些开关初始化uWSGI的脚本。 我将这个脚本复制到我的testing服务器,并使用它运行 service script.sh start 经过各种疑难解答,主要涉及对套接字文件夹等的权限,现在当我运行这个脚本启动,如果我运行htop我可以看到uWSGI正在运行,它有我需要的完全相同的命令开关。 我想简单地把脚本放在init.d中并给它执行权限 chmod +x script.sh 只要服务器启动就足够了,但这似乎不是这种情况。 因为当我问题 reboot 在terminal,terminal重新启动,但当我进入htops,并检查uWSGI进程没有运行。 […]

postgresql服务不在RHEL 7上运行

我们有一个在RHEL6 / 32位和RHEL6 / 64位上运行的应用程序。 这个应用程序从一开始就使用postgresql 8.4。 现在,我们要在RHEL7 / 64位上为这个应用程序提供支持。 RHEL7在其yum列表中默认使用postgresql 9.2,并且正在安装,其相关服务也正常运行。 但在RHEL7上安装postgresql 8.4后,似乎服务从未运行。 请在日志下面find: [root@linpubn218 postgres]# service postgresql status postgresql.service – SYSV: PostgreSQL database server. Loaded: loaded (/etc/rc.d/init.d/postgresql) Active: failed (Result: resources) since Mon 2016-07-25 12:40:28 IST; 2h 0min ago Docs: man:systemd-sysv-generator(8) Jul 25 12:40:26 linpubn218.gl.avaya.com systemd[1]: Starting SYSV: PostgreSQL database server…. Jul 25 […]

在linux上启动一个脚本的最好方法是什么?

我想开始一个脚本,当系统启动并寻找最佳方法时,我的方法是: vi /etc/systemd/system/myscript.service [Service] Type=simple ExecStart=/usr/bin/myscript CPUSchedulingPolicy=rr CPUSchedulingPrioty=27 [Install] WantedBy=multi-user.target graphical.target systemctl daemon-reload; systemctl enable myscript; systemctl start rmyscript 它运作良好,但只是想知道如果有另一种更好的方法。

while bash脚本中的循环打破了systemd服务

我在Debian上,我有一个systemd服务,调用一个bash脚本。 该脚本包含一个无限的while循环,因为我需要它无限地检查每X秒。 系统服务一旦遇到“while true; do”行,就会崩溃。 脚本运行正常,如果我手动执行它。 为什么不像系统一样? 我该怎么办? 这里是服务和脚本。 正如我所指出的那样,在“while true; do”之前打印回显语句。 “while true; do”行之后的echo语句不打印。 /etc/systemd/system/stream.service: [Service] WorkingDirectory=/home/pi/ ExecStart=/home/pi/joi_main.sh Restart=no StandardOutput=syslog StandardError=syslog SyslogIdentifier=stream_service User=pi Group=pi Environment=NODE_ENV=production [Install] WantedBy=multi-user.target /home/pi/joi_main.sh: #!/bin/bash -e today=`/bin/date '+%Y_%m_%d__%H_%M_%S'` exec 2> "/home/pi/stream_logs/$today.$RANDOM.log" exec 1>&2 #Wait 120s for system to finish booting sleep 120 #Initial config export AUDIODEV=mic_mono export AUDIODRIVER=alsa sudo sysctl […]

Debian systemd服务在networking准备就绪之前启动

操作系统:Debian Jessie 我想在每次系统启动时更新用户文件夹中的git仓库。 我试着用cron @reboot入口。 克朗开始得太早,结果邮寄给我“SSH:无法parsing主机名…” 然后我尝试了SysV init脚本。 效果 – 相同。 目前我正在尝试使用相同错误报告的systemd服务。 在/ usr / bin中/ git_repo #! /bin/sh # Description: Updates local git repository with latest content #cd /home/tanglor/repo su -c'cd repo;git pull' – tanglor /etc/systemd/system/repo.service [Unit] Description = Updates local git repository with latest content Wants=network-online.target After=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/repo [Install] WantedBy=multi-user.target 仍然没有结果。 […]

使用systemd,我如何识别冷启动与服务中的重启?

我正试图在Debian上执行一个systemd服务。 但是,我需要根据是否启动“冷”或重新启动来改变逻辑。 我目前有一个run-application.service ,看起来像这样: [Unit] Description=Run application [Service] Type=oneshot ExecStart=/usr/bin/run-application [Install] WantedBy=graphical.target 我希望在每次启动时调用程序,但是在重新启动的情况下需要修改内部逻辑。 什么是实现这个最简单/最好的方法?

systemd能否自动重启/停止依赖服务?

出于性能原因,我需要运行一个应用程序的多个实例,固定到CPU,在不同的端口上侦听。 一个HAProxy TCP负载均衡器位于它们前面,用于分配stream量。 这样做是为了防止任何线程上下文切换,并强制执行无共享devise(因此不需要应用程序中的任何types的锁,假设它是单线程的)。 所以这意味着在一个有64个CPU的服务器上,我可能会将HAProxy固定到CPU 0,然后将我的应用程序的63个实例分别固定到独立的CPU(1-63)。 显然,在启动,重启,关机等方面的pipe理相当复杂。 我想知道是否有任何方法可以使用systemd来处理这个复杂的问题。 我知道,如果我将HAProxy定义为一个单元,然后声明它需要与其他应用程序交谈,它可以解决启动问题,例如 Require=app1,app2,…..,app63 我可以 systemctl start myhaproxy 它会首先启动它需要的63个实例(假设在应用程序安装过程中,每个实例都被定义为一个单独的systemd单元)。 但是,我想知道是否有反正我也可以得到这个也适用于重新启动和关机。 所以如果我这样做: systemctl stop myhaproxy 我希望它会自动closures应用程序的63个实例。 如果我这样做 systemctl restart myhaproxy 那么我希望它在重新启动自己之前首先重新启动Require中列出的所有服务。 那可能吗? 还是超出了系统提供的范围?