daemon

Sequentially run commands in bash script

安稳与你 提交于 2019-12-08 12:04:00
问题 I need to run two commands sequentially in daemon mode (the commands will output the errors on stderr). The problem is that even I dump all the output in /dev/null, the second command (run_cmd2) cannot be invoked. Here is my script #! /bin/bash nohup ./run_cmd1 &> /dev/null & nohup ./run_cmd2 &> /dev/null & Any ideas? Thank you in advance. 回答1: How about using a file to communicate state? run_cmd2 will wait until a file exists before running when run_cmd1 is done, it will create the said file

Supervisorctl does not auto-restart daemon queue worker when hanging

旧时模样 提交于 2019-12-08 07:33:27
问题 I have supervisorctl managing some daemon queue workers with this configuration : [program:jobdownloader] process_name=%(program_name)s_%(process_num)03d command=php /var/www/microservices/ppsatoms/artisan queue:work ppsjobdownloader --daemon --sleep=0 autostart=true autorestart=true user=root numprocs=50 redirect_stderr=true stdout_logfile=/mnt/@@sync/jobdownloader.log Sometimes some workers are like hanging (running but stop getting queue messages) and supervisorctl does not automatically

Automatically restarting HHVM when it stops responding but process not dead

你。 提交于 2019-12-08 02:29:25
问题 I'm having a problem where every 12-24 hours, HHVM crashes but it seems to leave the process running. It seems most providers just use php5-fpm as a failover within nginx for stability. However, this won't restart the non-responsive hhvm instance. Since the process is left running, most server monitoring solutions will see it as a live daemon, and not restart it. HTTP monitoring can be slow to react. Is it possible to trigger the hhvm restart on failover? If not, what would be the best

How do I write a watchdog daemon in bash?

天大地大妈咪最大 提交于 2019-12-08 02:27:06
问题 I want a way to write a daemon in a shell script, which runs another application in a loop, restarting it if it dies. When run using ./myscript.sh from an SSH session, it shall launch a new instance of the daemon, except if the daemon is already running. When the SSH session ends, the daemon shall persist. There shall be a parameter ( ./myscript -stop ) that kills any existing daemon. ( Notes on edit - The original question specified that nohup and similar tools may not be used. This

Communicating over XPC with an app and launch daemon running as root

家住魔仙堡 提交于 2019-12-08 00:01:52
问题 Is it possible to communicate with a launch daemon running as root and an application over XPC? When my daemon is running as my user I can communicate with it fine, when run as root it stops receiving my messages. Is this intended security inside Mac OS X? I need to use low level xpc (for running on Lion as well). I know I can create a priviliged and signed helper tool that is running as root for my app. Will I be able to communicate with it with another process as well over XPC or sockets?

Is it possible to add an event handling to ZeroMQ to act when data is received/sent?

孤者浪人 提交于 2019-12-07 23:22:20
问题 I have created two unrelated daemon processes in C in Linux Ubuntu. These processes are in the sleeping mode, they only wake up when the data is received, and perform the action implemented in the signal handler and again sleep. I have implemented this communication using SIGNAL IPC and message queue. Before sending the message, I send the signal SIGUSR1 and then send the data, and I wrote the signal handler for SIGUSR1 to perform required action. I would like to implement the same way of

Puma - Rails on linux // Restart when process dies

时间秒杀一切 提交于 2019-12-07 17:54:53
问题 Using puma on a rails app; it sometimes dies without any articular reason; also often dies (does not restart after being stopped) when deployed What would be a good way to monitor if the process died, and restart it right way ? Being called within a rails app; I'd be useful to have a way to defines it for any apps. I did not found any useable ways to do it (looked into systemd, other linux daemons… no success) Thanks if any feedback 回答1: You can use puma control to start/stop puma server. If

Approach for installing system service implemented as Ruby gem

ε祈祈猫儿з 提交于 2019-12-07 15:24:23
问题 After years of being away from Ruby, I'm back full-force and have just cut my first gem, which includes an executable. Everything works like a charm. The problem I am facing, however, is that I ALSO have a startup script (not part of the gem istelf) that daemonizes the executable. Additionally, I'd also like for the startup script to point the executable at configuration in a place like /var/ To the best of my knowledge, there's no way with rubygems, gemspec, etc., to specify files getting

daemon函数结合脚本实现start, stop, restart

六月ゝ 毕业季﹏ 提交于 2019-12-07 14:47:43
1. daemon函数 Daemon程序是一直运行的服务端程序,又称为守护进程。通常在系统后台运行,没有控制终端不与前台交互,Daemon程序一般作为系统服务使用。Daemon是长时间运行的进程,通常在系统启动后就运行,在系统关闭时才结束。一般说Daemon程序在后台运行,是因为它没有控制终端,无法和前台的用户交互。Daemon程序一般都作为服务程序使用,等待客户端程序与它通信。我们也把运行的Daemon程序称作守护进程 int daemon ( int __nochdir , int __noclose ) ; 如果__nochdir的值为0,则将切换工作目录为根目录; 如果__noclose为0,则将标准输入,输出和标准错误都重定向到/dev /null。 经过这个函数调用后的程序将运行在后台,成为一个daemon程序,而linux下大多的服务都是以此方式运行的 2. daemon实例 最后生成的路径:/home/pc/workspace/daemon/test #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> int main(int argc, char *argv[]) { FILE* pidfp = fopen( "kmc_sa.pid", "w" );

Docker实战-编写Dockerfile

会有一股神秘感。 提交于 2019-12-07 14:44:46
一、编译镜像 1. 编译镜像 Dockerfile类似于Makfile,用户使用 docker build 就可以编译镜像,使用该命令可以设置编译镜像时使用的CPU数量、内存大小、文件路径等 语法:docker build [OPTIONS] PATH| URL| - 常见选项: -t 设置镜像的名称和TAG,格式为name:tag -f Dockerfile的名称,默认为PATH/Dockerfile 例子:docker build -f ~/php.Dockerfile . 注意:PATH是编译镜像使用的工作目录,Docker Daemon在编译开始时,会扫描PATH中的所有文件,可以在编译目录中加入.dockerignore过滤不需要的文件 Docker Daemon从Dockerfile中顺序读取指令,生成一个临时容器,在容器中执行指令,容器编译成功后会提交作为镜像层加入最终镜像,为了加快编译过程,Docker Daemon采用了缓存机制,如果在缓存中找到了需要的中间镜像则直接使用该镜像而不生成临时容器(编译时可以使用选项–no-cache选择不使用缓存) 2. dockerignore文件 编译开始前,Docker Daemon会读取编译目录中的.dockerignore文件,忽略其中的文件和目录,在其中可以使用通配符(?代表一个字符,*代表零个或任意个字符)