etcd交予systemd管理,start时状态217不成功 5C

日志信息如下:

 Feb 06 05:04:48 master-15 systemd[1]: Unit etcd.service entered failed state.
Feb 06 05:04:48 master-15 systemd[1]: etcd.service failed.
Feb 06 05:04:54 master-15 systemd[1]: etcd.service holdoff time over, scheduling restart.
Feb 06 05:04:54 master-15 systemd[1]: Starting Etcd Server...
-- Subject: Unit etcd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit etcd.service has begun starting up.
Feb 06 05:04:54 master-15 systemd[16498]: Failed at step USER spawning /usr/bin/etcd: No such pr
-- Subject: Process /usr/bin/etcd could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The process /usr/bin/etcd could not be executed and failed.
-- 
-- The error number returned by this process is 3.
Feb 06 05:04:54 master-15 systemd[1]: etcd.service: main process exited, code=exited, status=217
Feb 06 05:04:54 master-15 systemd[1]: Failed to start Etcd Server.
-- Subject: Unit etcd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit etcd.service has failed.
-- 
-- The result is failed.
Feb 06 05:04:54 master-15 systemd[1]: Unit etcd.service entered failed state.
Feb 06 05:04:54 master-15 systemd[1]: etcd.service failed.

etcd.service如下:

[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
User=etcd
# set GOMAXPROCS to number of processors
ExecStart=/usr/bin/etcd \
  --name=etcd1 \
  --cert-file=/etc/kubernetes/ssl/etcd.pem \
  --key-file=/etc/kubernetes/ssl/etcd-key.pem \
  --peer-cert-file=/etc/kubernetes/ssl/etcd.pem \
  --peer-key-file=/etc/kubernetes/ssl/etcd-key.pem \
  --trusted-ca-file=/etc/kubernetes/ssl/ca.pem \
  --peer-trusted-ca-file=/etc/kubernetes/ssl/ca.pem \
  --initial-advertise-peer-urls=https://192.168.230.15:2380 \
  --listen-peer-urls=https://192.168.230.15:2380 \
  --listen-client-urls=https://192.168.230.15:2379,http://127.0.0.1:2379 \
  --advertise-client-urls=https://192.168.230.15:2379 \
  --initial-cluster-token=k8s-etcd-cluster \
  --initial-cluster=etcd1=https://192.168.230.15:2380 \
  --initial-cluster-state=new \
  --data-dir=/var/lib/etcd
Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target


shenren250
墨汁儿 回复樱桃小李子: 后来实际上没有解决,于是就美哟iu再用二进制的方式配置kubernetes了,后来用来kubeadm配置的集群
7 个月之前 回复
hard_lee
樱桃小李子 请问这个问题最后怎么解决的呀 求解答
一年多之前 回复

1个回答

对照这个看下你的配置文件 https://www.cnblogs.com/vipmint/p/5694114.html

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
CentOS7 systemd管理mysql的一个问题

基础环境版本: CentOS7.3 原生mysql5.7 我是通过下载官网的rpm包进行安装mysql-server的, 问题现象: 通过使用官网下载的rpm安装好mysql-server后,在配置文件中配置好mysql服务端 ![图片说明](https://img-ask.csdn.net/upload/201809/25/1537865812_725068.jpg) 创建好相关目录,配置好权限后,使用systemct启动应用 但是当我查看启动的mysql进程时,突然发现pid-file是/var/run/mysqld/mysqld.pid,但是我配置中写的是/opt/mysql/3306/tmp/mysqld.pid![图片说明](https://img-ask.csdn.net/upload/201809/25/1537866258_197098.jpg) 查看了一下,发现/usr/lib/systemd/system/mysqld.service(mysql的systemd注册服务文件)中已经把mysql的pid文件名写死了![图片说明](https://img-ask.csdn.net/upload/201809/25/1537866276_212217.jpg) 再次尝试修改pid文件路径,改为/opt/mysql/3306/tmp/mysqld.pid![图片说明](https://img-ask.csdn.net/upload/201809/25/1537866343_369532.jpg) 使用systemctl daemon-reload重新加载mysqd.service文件 再次使用systemctl启动mysqld,但是这时,mysqld进程启动正常,pid文件也写入了正确的路径中,但是systemctl一直没有返回,另起一个section,用systemctl status mysqld查询状态,发现mysqld一直处于activating (start)状态![图片说明](https://img-ask.csdn.net/upload/201809/25/1537866644_455249.jpg) 这时mysql-server可以正常使用,systemctl start mysqld的进程强制停掉也不会影响正常使用,但mysqld的服务状态也不会变为正常的active (running) 兄弟们有遇到过类似的状况么??求解一下,这个是什么原理?

如何在systemd服务中正确设置php脚本?

<div class="post-text" itemprop="text"> <p>SO, I'm trying to set up a service using systemd on an Axis camera (I believe it's Arch linux or a very stripped down Linux version that's custom). I have the service set up as follows:</p> <p>myservice.service:</p> <pre><code>[Unit] Description=Ping Monitoring Daemon After=network.target After=network-online.target [Service] Type=oneshot ExecStart=/etc/init.d/listen-start.sh ExecStop=/etc/init.d/listen-stop.sh RemainAfterExit=yes [Install] WantedBy=multi-user.target </code></pre> <p>Here is listen-start.sh:</p> <pre><code>#!/bin/sh echo $(curl http://website.com/logssomethingtoadatabase.php?action=start) </code></pre> <p>My php script:</p> <pre><code>&lt;?php echo 'Service Started'; while (true) { $foo = print_r($_SERVER, true); $blnStop = false; if ( $_GET['action'] === 'start') { mail("test@myemail.com","Debug", "Camera service started with current values: " . $foo); } else { mail("test@myemail.com","Debug", "Camera service stopped with current values: " . $foo); $blnStop = true; } if ( $blnStop ) { break 2; } sleep(60); } echo 'Service Stopped'; die(); ?&gt; </code></pre> <p>Issue I'm encountering is once I start the service, I'm unable to "stop it", even after issuing the "systemctl stop" and "disable" commands on it. I have to power cycle the camera to get it to stop emailing me. I can't seem to get it to "break" out of the while loop.</p> <p>The goal here is to call that script every 60 seconds which is a device monitoring effort. I must use systemd in this case as that's all that the camera supports.</p> <p>Additional info: The systemctl start and stop commands work successfully, and the script itself runs fine.</p> <p>Can anyone see anything I may be missing?</p> </div>

Linux systemd 自启动脚本无法正常运行(求助分析方向)

在RHEL8.0上,通过systemd service用以下脚本来实现登录后自动切换壁纸。 服务为test.service, bash脚本为test.sh 单独运行Set_background.sh 没有问题,但是当通过test.service去调用的时候,只能设置一次。 设置壁纸的命令成功,但是重置的命令失败。 考虑是因为通过test.service去调用test.sh时,线程出现问题。 请高手指教从哪里去分析。 **test.service内容如下:** ``` [Unit] Description=Change Desktop background [Service] ExecStart=/home/test/Desktop/Set_background.sh After=gdm.service [Install] WantedBy=graphical.target ``` **Set_background.sh内容如下:** ``` #!/bin/bash while true do /usr/bin/gsettings set org.gnome.desktop.background picture-uri 'file:///home/test/Desktop/8-dark.xml' sleep 3 /usr/bin/gsettings reset org.gnome.desktop.background picture-uri sleep 3 done ```

从systemd启动主进程时无法分离子进程

<div class="post-text" itemprop="text"> <p>I want to spawn long-running child processes that survive when the main process restarts/dies. This works fine when running from the terminal:</p> <pre><code>$ cat exectest.go package main import ( "log" "os" "os/exec" "syscall" "time" ) func main() { if len(os.Args) == 2 &amp;&amp; os.Args[1] == "child" { for { time.Sleep(time.Second) } } else { cmd := exec.Command(os.Args[0], "child") cmd.SysProcAttr = &amp;syscall.SysProcAttr{Setsid: true} log.Printf("child exited: %v", cmd.Run()) } } $ go build $ ./exectest ^Z [1]+ Stopped ./exectest $ bg [1]+ ./exectest &amp; $ ps -ef | grep exectest | grep -v grep | grep -v vim snowm 7914 5650 0 23:44 pts/7 00:00:00 ./exectest snowm 7916 7914 0 23:44 ? 00:00:00 ./exectest child $ kill -INT 7914 # kill parent process [1]+ Exit 2 ./exectest $ ps -ef | grep exectest | grep -v grep | grep -v vim snowm 7916 1 0 23:44 ? 00:00:00 ./exectest child </code></pre> <p>Note that the child process is still alive after parent process was killed. However, if I start the main process from systemd like this...</p> <pre><code>[snowm@localhost exectest]$ cat /etc/systemd/system/exectest.service [Unit] Description=ExecTest [Service] Type=simple ExecStart=/home/snowm/src/exectest/exectest User=snowm [Install] WantedBy=multi-user.target $ sudo systemctl enable exectest ln -s '/etc/systemd/system/exectest.service' '/etc/systemd/system/multi-user.target.wants/exectest.service' $ sudo systemctl start exectest </code></pre> <p>... then the child also dies when I kill the main process:</p> <pre><code>$ ps -ef | grep exectest | grep -v grep | grep -v vim snowm 8132 1 0 23:55 ? 00:00:00 /home/snowm/src/exectest/exectest snowm 8134 8132 0 23:55 ? 00:00:00 /home/snowm/src/exectest/exectest child $ kill -INT 8132 $ ps -ef | grep exectest | grep -v grep | grep -v vim $ </code></pre> <p>How can I make the child survive?</p> <p>Running go version go1.4.2 linux/amd64 under CentOS Linux release 7.1.1503 (Core).</p> </div>

systemd在docker容器中

<div class="post-text" itemprop="text"> <p>I have a server with ubuntu 14.04 (that does not use systemd), I use HHVM but I want to use php 7 now. I was thinking, why not use a container with php7.0-fpm, this should work.</p> <p>I first tried with a centos 7 (that uses systemd) container, I could install everything, but the problem is when I try to start the service, I get this: "Failed to get D-Bus connection: Operation not permitted"</p> <p>In the end, I used an Ubuntu 14.04 container where I installed php7 with fpm and it worked, but will I get this problem every time I want to use am container that uses systemd from a system that doesn't? (and what about the opposite)</p> <p>Thank you :)</p> </div>

作为systemd服务运行时服务器内存不足

<div class="post-text" itemprop="text"> <p>I have created a webserver using the Echo router. It act as a REST endpoint. I tried to deploy it in an Ubuntu server using <code>systemd</code>. The requests are getting out of memory when I try to run it as a service. However it is working fine when I run it in terminal What could be the issue.</p> <p><strong>my service file</strong></p> <pre><code>[Unit] Description=myapp [Service] Type=simple User=root Environment=ENV=PRODUCTION ExecStart=/var/www/myapp/public_html/my.app Restart=always RestartSec=5s [Install] WantedBy=multi-user.target </code></pre> </div>

运行二进制作为systemd服务不起作用

<div class="post-text" itemprop="text"> <p>I have a go project and when I compile it I get your typical binary. If I call the binary directly from the command line with the adequate inputs, it runs perfectly well. I want to make this program part of the systemd ecosystem and the following is my my <code>gobinary.service</code></p> <pre><code>[Unit] Description=Run Go Service [Service] WorkingDirectory=/path/to/directory/ ExecStart=/path/to/directory/binary --config config/service.conf Restart=always [Install] WantedBy=multi-user.target </code></pre> <p>I can start and stop the service using the usual <code>sudo service gobinary start</code> without error messages but the problem is that the program is actually not running because it does not respond to the inputs, namely it has a rabbitmq input queue, despite me sending content to the queue it doesn't react. If however I run the program using the binary directly <code>$ ./binary --config/service.conf</code> everything runs smoothly. How do I troubleshoot this?</p> </div>

为什么systemd无法启动golang Web应用程序,没有答案

<div class="post-text" itemprop="text"> <p>My golang web app cannot start when I use systemd, but it works fine when manually start. What are problems with my systemd configuration?</p> <p><strong>goweb.service</strong></p> <pre><code>$ cat goweb.service [Unit] Description=Backend service After=network.target [Service] User=myapp Group=myapp Restart=on-failure ExecStart=/u01/backend [Install] WantedBy=multi-user.target </code></pre> <p><code>backend</code> is a binary file compiled with command: <code>env GOOS=linux GOARCH=amd64 go build -v bitbucket.org/myapp/backend</code></p> <p><strong>systemd service status</strong></p> <pre><code>$ sudo service goweb status Redirecting to /bin/systemctl status goweb.service ● goweb.service - Backend service Loaded: loaded (/usr/lib/systemd/system/goweb.service; disabled; vendor preset: disabled) Active: inactive (dead) May 18 10:55:56 instance-1 systemd[1]: Started Backend service. May 18 10:55:56 instance-1 systemd[1]: Starting Backend service... </code></pre> <p><strong>P/S</strong>: It looks like my web app started, but then stoped immediately.</p> <p>I try config <code>Type=forking</code>, then service status show as below. Could someone explains why the log <code>Started Backend service.</code> and <code>Starting Backend service...</code> order is reversed.</p> <pre><code>$ sudo service goweb status Redirecting to /bin/systemctl status goweb.service ● goweb.service - Backend service Loaded: loaded (/usr/lib/systemd/system/goweb.service; enabled; vendor preset: disabled) Active: inactive (dead) since Wed 2016-05-18 11:06:02 UTC; 2s ago Process: 25847 ExecStart=/u01/backend (code=exited, status=0/SUCCESS) May 18 11:06:02 instance-1 systemd[1]: Starting Backend service... May 18 11:06:02 instance-1 systemd[1]: Started Backend service. </code></pre> <p>Result when I run web app manually (from terminal):</p> <pre><code>$ /u01/backend [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) [GIN-debug] POST /upload --&gt; main.uploadFileHandler (3 handlers) [GIN-debug] Environment variable PORT="9005" [GIN-debug] Listening and serving HTTP on :9005 </code></pre> <hr> <p><strong>Update</strong>:</p> <ol> <li>I try <a href="http://supervisord.org/" rel="nofollow">supervisord</a> and it works fine (same binary file)</li> <li>With <code>systemd</code>, I changed service config to <code>Restart=always</code>, <code>RestartSec=15</code>. And <code>systemd</code> keeps restarting my web app.</li> </ol> <p>Does anyone know why <code>supervisord</code> work fine but <code>systemd</code> not? I think that <code>systemd</code> would work fine with a basic task like that!</p> </div>

liunx 安装 systemd-219-42.el7.x86_64.rpm

为啥总是有那么多要安装啊!求大神指点 rpm -ivh systemd-219-42.el7.x86_64.rpm warning: systemd-219-42.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY error: Failed dependencies: kmod >= 18-4 is needed by systemd-219-42.el7.x86_64 libc.so.6(GLIBC_2.16)(64bit) is needed by systemd-219-42.el7.x86_64 libc.so.6(GLIBC_2.17)(64bit) is needed by systemd-219-42.el7.x86_64 libcryptsetup.so.4()(64bit) is needed by systemd-219-42.el7.x86_64 libcryptsetup.so.4(CRYPTSETUP_1.0)(64bit) is needed by systemd-219-42.el7.x86_64 libkmod.so.2()(64bit) is needed by systemd-219-42.el7.x86_64 libkmod.so.2(LIBKMOD_5)(64bit) is needed by systemd-219-42.el7.x86_64 liblzma.so.5()(64bit) is needed by systemd-219-42.el7.x86_64 liblzma.so.5(XZ_5.0)(64bit) is needed by systemd-219-42.el7.x86_64 libmount.so.1(MOUNT_2.20)(64bit) is needed by systemd-219-42.el7.x86_64 libqrencode.so.3()(64bit) is needed by systemd-219-42.el7.x86_64 systemd-libs = 219-42.el7 is needed by systemd-219-42.el7.x86_64 dracut < 033-499 conflicts with systemd-219-42.el7.x86_64 initscripts < 9.49.28-1 conflicts with systemd-219-42.el7.x86_64

我的系统服务有什么问题

<div class="post-text" itemprop="text"> <p>I have written a golang RestAPI based on labstack/echo and vuejs and have a working version compiled and everything runs nicely when I start it. So far so good.</p> <p>However when trying to integrate it with systemd to start the process at boot I am stuck. I have a service file.</p> <pre><code>[Unit] Description=Server Software Manager After=network.target [Service] Type=simple ExecStart=/var/gameserver/steam/sman KillMode=process User=steam Group=steam Restart=on-failure SuccessExitStatus=2 [Install] WantedBy=multi-user.target Alias=sman.service </code></pre> <p>But everytime I want to start the service I get the following error.</p> <pre><code>Feb 25 14:17:49 &lt;SERVERNAME&gt; systemd[1]: Stopped Server Software Manager. Feb 25 14:17:49 &lt;SERVERNAME&gt; systemd[1]: Started Server Software Manager. Feb 25 14:17:49 &lt;SERVERNAME&gt; systemd[1]: sman.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Feb 25 14:17:49 &lt;SERVERNAME&gt; systemd[1]: sman.service: Unit entered failed state. Feb 25 14:17:49 &lt;SERVERNAME&gt; systemd[1]: sman.service: Failed with result 'exit-code'. Feb 25 14:17:50 &lt;SERVERNAME&gt; systemd[1]: sman.service: Service hold-off time over, scheduling restart. Feb 25 14:17:50 &lt;SERVERNAME&gt; systemd[1]: Stopped Server Software Manager. Feb 25 14:17:50 &lt;SERVERNAME&gt; systemd[1]: sman.service: Start request repeated too quickly. Feb 25 14:17:50 &lt;SERVERNAME&gt; systemd[1]: Failed to start Server Software Manager. Feb 25 14:19:59 &lt;SERVERNAME&gt; systemd[1]: Started Server Software Manager. </code></pre> <p>According to google that error is when the Service exits with error code but when I run the Service manually as the steam user it does not do that.</p> <p>My assumption is that something is wrong with that unit file but I don't know what. And Systemd-analyze has also not complained. I am completely lost and thankful for any leads you might have help debug this.</p> <p>The output of jounarlctl -xfe -u sman:</p> <pre><code>Feb 26 14:18:23 &lt;SERVERNAME&gt; systemd[1]: Started Server Software Manager. -- Subject: Unit sman.service has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit sman.service has finished starting up. -- -- The start-up result is done. </code></pre> <p>Notes: OS: Ubuntu 16.04 LTS</p> </div>

Nginx启动时service nginx start出现错误

命令service nginx start 出现错误 Starting nginx (via systemctl):  Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.                                                            [FAILED] 然后查看详情systemctl status nginx.service systemctl status nginx.service ● nginx.service - SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server    Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled)    Active: failed (Result: exit-code) since Sun 2019-07-07 15:51:25 CST; 8s ago      Docs: man:systemd-sysv-generator(8)   Process: 22685 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=5)Jul 07 15:51:25 iZwz9gionemu6x0y9pvxihZ systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3...ver... Jul 07 15:51:25 iZwz9gionemu6x0y9pvxihZ systemd[1]: nginx.service: control process exited, code=exited status=5 Jul 07 15:51:25 iZwz9gionemu6x0y9pvxihZ systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IM...erver. Jul 07 15:51:25 iZwz9gionemu6x0y9pvxihZ systemd[1]: Unit nginx.service entered failed state. Jul 07 15:51:25 iZwz9gionemu6x0y9pvxihZ systemd[1]: nginx.service failed. 是什么问题啊

如何注册systemd服务生命周期事件?

<div class="post-text" itemprop="text"> <p>I want to be informed about all state changes of service units. I know there is the DBUS API which gives me signals for UnitNew and UnitRemoved, but the semantic is still unclear to me. Also the signals doesn't provide the informations I need.</p> <p>I'm using go and tried the <a href="https://github.com/coreos/go-systemd" rel="nofollow noreferrer">go-systemd lib</a> from coreos. They provide a way to "subscribe" but it's in fact polling all the unit information available in the system. I do not want to do so every few milliseconds, just to get informed about statechanges.</p> <p>I also tried the default org.freedesktop.DBus.Properties but I can not get this working.</p> <p>Please help If you can, I'm out of ideas.</p> </div>

Linux display命令在终端中起作用,但在systemd服务中不起作用

<div class="post-text" itemprop="text"> 我制作了一个网络应用程序来关闭计算机的屏幕,虽然有几种不同的技术,但是非常简单: 我有一个html / js前端,它检测按钮单击(屏幕打开/屏幕关闭),该按钮通过ajax将选项发送到PHP后端 然后,PHP通过TCP端口连接,将选项发送到用golang编写的程序 然后,我的golang程序执行命令以关闭/打开屏幕。 它运行的命令是(“ xset -display:0 dpms force off”) 我遇到的问题是该命令仅在在终端中运行golang程序时才有效,但是当我将其设置为服务时,该命令将不起作用。 这是golang代码: <pre><code>package main import ( "os/exec" "net" "fmt" "bufio" ) func main() { fmt.Println("Launching server") ln, _ := net.Listen("tcp", ":7777") fmt.Println("Listening... ") for { // accept connection on port conn, _ := ln.Accept() fmt.Println("New connection") // listen for message ending in message, _ := bufio.NewReader(conn).ReadString(' ') rec := string(message) // remove trailing rec = rec[:len(rec)-1] fmt.Println("Message Received: ", "\""+rec+"\"") returnMessage := "fail" if (rec == "screensOff") { fmt.Println("Turning off screens...") //execute screens off command cmd := exec.Command("xset", "-display", ":0", "dpms", "force", "off") stdout, err := cmd.Output() if err != nil { fmt.Println(err.Error()) } else { fmt.Println(string(stdout)) returnMessage = "done" } } else if (rec == "screensOn") { fmt.Println("Turning on screens..."); //execute screens on command cmd := exec.Command("xset", "-display", ":0", "dpms", "force", "on") stdout, err := cmd.Output() if err != nil { fmt.Println(err.Error()) } else { fmt.Println(string(stdout)) returnMessage = "done" } returnMessage = "done" } conn.Write([]byte(returnMessage + " ")) conn.Close() fmt.Println("Connection closed ") } } </code></pre> <p>相关的PHP代码:</p> <pre><code>&lt;?php function sendServiceMessage($message) { $host = "localhost"; $port = 7777; $timeout = 30; // connect to service $socket = fsockopen($host, $port, $errnum, $errstr, $timeout); if (!is_resource($socket)) { exit("connection fail: ".$errnum." ".$errstr); } else { // send message fputs($socket, $message." "); // receive return message $recieved = ""; while (!feof($socket)) { $recieved .= fgets ($socket, 1024); } } // close connection fclose($socket); if ($recieved == "done") { return true; } return false; } sendServiceMessage("screensOff"); </code></pre> <p>我使用systemd来设置服务,因此在构建程序并将其放在/usr/bin/中之后/</p> <pre><code>...$ go build screenControl.go ...$ sudo cp screenControl /usr/bin/screenControl </code></pre> <p>I can run the screenControl program in the terminal, and select "screens off" in the web app and it all works as expected:</p> <pre><code>...$ screenControl Launching server Listening... New Connection Message Received: "screensOff" Turning off screens... Connection closed </code></pre> <p>然后,我创建了一个systemd单位文件(/etc/systemd/system/screenControl.service):</p> <pre><code>[Unit] Description=Screen control service [Service] ExecStart=/usr/bin/screenControl Restart=on-abort [Install] WantedBy=multi-user.target </code></pre> <p>于是我启动服务并检查了一下它:</p> <pre><code>...$ systemctl start screenControl ...$ systemctl status screenControl ● screenControl.service - Screen control service Loaded: loaded (/etc/systemd/system/screenControl.service; disabled; vendor preset: enabled) Active: active (running) since Sun 2015-12-13 22:31:54 GMT; 6s ago Main PID: 19871 (screenControl) CGroup: /system.slice/screenControl.service └─19871 /usr/bin/screenControl Dec 13 22:31:54 User systemd[1]: Started Screen control service. Dec 13 22:31:54 User screenControl[19871]: Launching server Dec 13 22:31:54 User screenControl[19871]: Listening... </code></pre> <p>因此它正在运行,但是当我现在在Web应用程序中选择关闭屏幕时,什么也没发生...我再次检查了服务状态,它收到了关闭屏幕的消息,但是命令退出并出现错误:</p> <pre><code>... Dec 13 22:31:54 User screenControlTest[19871]: Launching server Dec 13 22:31:54 User screenControlTest[19871]: Listening... Dec 13 22:32:25 User screenControlTest[19871]: New connection Dec 13 22:32:25 User screenControlTest[19871]: Message Received: "screensOff" Dec 13 22:32:25 User screenControlTest[19871]: Turning off screens... Dec 13 22:32:25 User screenControlTest[19871]: exit status 1 Dec 13 22:32:25 User screenControlTest[19871]: Connection closed </code></pre> <p>这是什么问题,如何使该命令作为服务工作? 一旦运行正常,我想在机器开机时自动启动服务,尽管使用systemd我认为这很简单:</p> <pre><code>...$ systemctl enable screenControl </code></pre> 任何帮助将是伟大的,谢谢:) 编辑: 在让golang程序显示xset命令的stderr之后,我现在也有了错误消息: <pre><code>xset: unable to open display "" </code></pre> </div>

CentOs 7 服务vsptd 启动失败,求大神!

systemctl status vsftpd.service vsftpd.service - Vsftpd ftp daemon Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled) Active: failed (Result: exit-code) since Sat 2015-09-26 10:46:32 CST; 6s ago Process: 2162 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=2) Sep 26 10:46:32 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon... Sep 26 10:46:32 localhost.localdomain systemd[1]: vsftpd.service: control process exited, code=exited status=2 Sep 26 10:46:32 localhost.localdomain systemd[1]: Failed to start Vsftpd ftp daemon. Sep 26 10:46:32 localhost.localdomain systemd[1]: Unit vsftpd.service entered failed state. journalctl -xn Sep 26 10:46:32 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon... -- Subject: Unit vsftpd.service has begun with start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit vsftpd.service has begun starting up. Sep 26 10:46:32 localhost.localdomain systemd[1]: vsftpd.service: control process exited, code=exited status=2 Sep 26 10:46:32 localhost.localdomain systemd[1]: Failed to start Vsftpd ftp daemon. -- Subject: Unit vsftpd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit vsftpd.service has failed. -- -- The result is failed. Sep 26 10:46:32 localhost.localdomain systemd[1]: Unit vsftpd.service entered failed state.

xen服务无法启动,PID file not needed on systemd

项目需要,在centos系统上搭建xen系统,通过源码编译安装后启动xen服务始终报错: service xencommons start Starting /usr/local/sbin/xenstored...FATAL: /usr/local/sbin/xenstored: PID file not needed on systemd .............................. Could not start xenstored 但通过xl info又可以查看当前xen的信息。百度谷歌了很久,这个问题一直没有解决,求请教。 (ps:最初安装了xen-4.7.0,但通过make uninstall进行了卸载,重装xen-4.5.0就报这个错误,不知道原因是什么)

尝试在systemd下运行可访问X服务器的服务

<div class="post-text" itemprop="text"> <p>I'm using manjaro linux (arch based) with systemd. I want to make a daemon service that runs in the background and takes screenshots of my screen at random intervals, up to 10 minutes apart.</p> <p>I'm using Go, and I have a program that works just fine if I build it and run it from the command line (see below). I've made a .service file (see below) for the service and I've started it with <code>systemctl start screenshot</code> and confirmed it's running with <code>systemctl is-active screenshot</code>. However, it doesn't work. No screenshots are being saved like if I run it from the command line.</p> <p>Out of interest I tried running it with <code>nohup ./screenshot &amp;</code> and it suffers from the same problem as my daemon attempt.</p> <p>Is there some sort of problem with using the date package in the background? Or could it perhaps be the screenshot library?</p> <p><code>screenshot.go</code> </p> <pre><code>package main import ( "fmt" "image/png" "math/rand" "os" "time" "github.com/coreos/go-systemd/daemon" "github.com/vova616/screenshot" ) func main() { daemon.SdNotify(false, "READY=1") i := 0 for { r := rand.Intn(10) time.Sleep(time.Duration(r) * time.Minute) t := time.Now() year, month, day := t.Date() date := fmt.Sprintf("%d-%s-%d", year, month.String(), day) img, err := screenshot.CaptureScreen() if err != nil { fmt.Println(err) continue } hour, min, sec := t.Clock() stamp := fmt.Sprintf("%d:%d:%d", hour, min, sec) fmt.Printf("Taking screenshot %s ", stamp) f, err := os.Create(fmt.Sprintf("/home/dave/screenshot/%s/%s.png", date, stamp)) if err != nil { fmt.Println(err) continue } err = png.Encode(f, img) if err != nil { fmt.Println(err) continue } err = f.Close() if err != nil { fmt.Println(err) continue } i++ daemon.SdNotify(false, "WATCHDOG=1") } } </code></pre> <p>and here is the service file</p> <pre><code>[Unit] Description=Random Screenshot Service [Service] Type=notify ExecStart=/home/dave/screenshot/screenshot WatchdogSec=30s Restart=on-failure [Install] WantedBy=multi-user.target </code></pre> </div>

Systemd无法检测到GOPATH(在没有二进制文件的情况下运行)

<div class="post-text" itemprop="text"> <p>I wrote simple systemd service-file <code>goserver.service</code>:</p> <pre><code>[Unit] Description=Goserver [Service] ExecStart=/usr/bin/go run /home/denis/goserver/index.go [Install] WantedBy=multi-user.target </code></pre> <p>But when I try to run service and get status:</p> <pre><code>$ sudo systemctl status goserver.service </code></pre> <p>I get error:</p> <pre><code>мар 02 12:28:04 DV go[13627]: home/denis/goserver/index.go:6:2: cannot find package "gopkg.in/mgo.v2" in any of: мар 02 12:28:04 DV go[13627]: /usr/lib/go-1.6/src/gopkg.in/mgo.v2 (from $GOROOT) мар 02 12:28:04 DV go[13627]: ($GOPATH not set) </code></pre> <p>But <code>$GOPATH</code> is set with <code>export</code> command:</p> <pre><code>$ export GOPATH="/home/denis/goserver/" $ ls $GOPATH goserver.log index.go pkg src templates </code></pre> <p>And this command from command-line works fine:</p> <pre><code>$ /usr/bin/go run /home/denis/goserver/index.go </code></pre> <p>But if I use systemd service it doesn't work.</p> <p>How can I run systemd service with detected <code>$GOPATH</code>? (without binary file created by command <code>go build...</code>)</p> </div>

manjaro下安装了mysql8,之前都运行正常,突然启动不了了,应该怎么查?

[NBC1700155 mysql]# systemctl start mysqld Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [NBC1700155 mysql]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pres> Active: failed (Result: exit-code) since Wed 2019-11-06 21:14:40 CST; 8s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 3107 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0> Process: 3128 ExecStart=/usr/bin/mysqld $MYSQLD_OPTS (code=exited, status=127) Main PID: 3128 (code=exited, status=127) 11月 06 21:14:40 NBC1700155 systemd[1]: mysqld.service: Service RestartSec=100m> 11月 06 21:14:40 NBC1700155 systemd[1]: mysqld.service: Scheduled restart job, > 11月 06 21:14:40 NBC1700155 systemd[1]: Stopped MySQL Server. 11月 06 21:14:40 NBC1700155 systemd[1]: mysqld.service: Start request repeated > 11月 06 21:14:40 NBC1700155 systemd[1]: mysqld.service: Failed with result 'exi> 11月 06 21:14:40 NBC1700155 systemd[1]: Failed to start MySQL Server. [NBC1700155 mysql]#

启redis服务时报错,帮忙看下

[root@redhat ~]# service redis start Starting redis (via systemctl): Job for redis.service failed because the control process exited with error code. See "systemctl status redis.service" and "journalctl -xe" for details. [FAILED] [root@redhat ~]# [root@redhat ~]# [root@redhat ~]# service redis status 鈼[0m redis.service - SYSV: Redis is an open source, advanced key-value store. Loaded: loaded (/etc/rc.d/init.d/redis) Active: failed (Result: exit-code) since Wed 2019-04-03 14:25:04 CST; 3min 1s ago Docs: man:systemd-sysv-generator(8) Process: 4374 ExecStart=/etc/rc.d/init.d/redis start (code=exited, status=255) CGroup: /system.slice/redis.service 鈹斺攢3305 /usr/local/redis/bin/redis-server *:6379 Apr 03 14:25:04 redhat systemd[1]: Starting SYSV: Redis is an open source, advanced key-value store.... Apr 03 14:25:04 redhat redis[4374]: Starting Redis Server: [ OK ] Apr 03 14:25:04 redhat redis[4374]: /etc/rc.d/init.d/redis: line 29: [: $: integer expression expected Apr 03 14:25:04 redhat redis[4374]: /etc/rc.d/init.d/redis: line 30: return: $: numeric argument required Apr 03 14:25:04 redhat redis[4374]: /etc/rc.d/init.d/redis: line 66: exit: $: numeric argument required Apr 03 14:25:04 redhat systemd[1]: redis.service: control process exited, code=exited status=255 Apr 03 14:25:04 redhat systemd[1]: Failed to start SYSV: Redis is an open source, advanced key-value store.. Apr 03 14:25:04 redhat systemd[1]: Unit redis.service entered failed state. Apr 03 14:25:04 redhat systemd[1]: redis.service failed. /etc/init.d/redis: line 66: exit: $: numeric argument required

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐