daemon

Daemons in C - is there a way they're meant to be implemented?

ぃ、小莉子 提交于 2019-12-07 07:19:18
问题 I've got a general question about daemons in C, that I haven't seen an answer to by now. Is there a way how one should implement the control of a daemon process, like a convention or standard? --Rest is further explanation-- I have seen multiple documents teaching the basics how to create a daemon in C. Forking, closing file descriptors, changing root, etc... no problem. And they all stop, when the process enters a endless loop (when the daemon process is created - so to say). But this is

New to Java EE; architecture suggestions for a service/daemon?

依然范特西╮ 提交于 2019-12-07 05:21:44
问题 I am brand new to the Java EE world. As an exercise to try and familiarize myself with Java EE, I'm trying to create a tiered web-app, but I'm getting a little stuck on what the best way is to spin up a service in the background that does work. Parameters of the service: It must open and hold a socket connection and receive information from the connected server. There is a 1-to-1 correlation between a user and a new socket connection. So the idea is the user presses a button on the web-page,

celery daemon - permission denied on log file

冷暖自知 提交于 2019-12-07 04:54:43
问题 I have been working on setting up my celery task as a daemon in order to process data on a schedule. I have been following the docs in order to set up my daemon, but have been running into a log file permission error that has me stumped. Below is the configuration i have set up on an ubuntu box on Digital Ocean /etc/default/celeryd # here we have a single node CELERYD_NODES="w1" CELERY_BIN = "/mix_daemon/venv/bin/celery" CELERYD_CHDIR="/mix_daemon/" CELERYD_OPTS="-A tasks worker --loglevel

How to make uwsgi --emperor run as daemon

时间秒杀一切 提交于 2019-12-07 04:35:47
问题 I'm using yaml. It has a line says : daemonize : /var/www/apps/myapp.log If uwsgi -y vassals/myappconfig.yaml , the website runs in background. I can do other things in terminal, even logout. This is the effect I'm expecting. If uwsgi --emperor vassals , the website can run, but it stuck up in terminal. I must use ctrl + c to end it to return to terminal. Then the website is down. That's not what I'm expecting. I don't want to use things like nohup . If uwsgi --emperor is not the right

用KV系统实现并发锁

守給你的承諾、 提交于 2019-12-07 03:51:21
在key-value系统中缓存了网络服务器上一个重要的ticket,这个ticket用来授权。在一定的时间周期7200s里更新。现需要实现一个CGI提供给前端获取这个ticket,CGI访问量为每天百万pv左右。 假设某一时刻ticket要过期时有A,B两个请求。A请求过来发现ticket过期,开始从网络服务器上获取最新的ticket并写入KV,同时服务器更新自己存储的ticket。而B恰好在A写入前读出了ticket,此时服务器上的ticket和A同步了。但B的ticket是过期的,这会导致用B获取的ticket去请求资源时失败。 因而需要读写分离。其实读写分离也意味着把 并发锁转移 ,从可能几K个并发争锁减少到几个并发争锁。同时在CGI中降低了加锁成本。 思路如下: CGI只进行读KV操作 实现一个daemon程序,只负责每隔固定周期往KV更新ticket。用一个并发锁去控制写入时的资源竞争。 KV实现并发锁 往KV里添加一个字段 daemon_mutex ,对应的value为 pid + timestamp 。 daemon可能会挂掉。挂掉会导致两方面问题 daemon进程占有写锁,挂掉后死锁 daemon进程挂掉后KV不会更新 因此可以启动三个daemon进程,相互监督。 步骤如下: 3个进程争写锁,争到的进程为主进程,每隔1s刷新KV中 daemon_mutex

Python daemonize

纵然是瞬间 提交于 2019-12-07 01:55:18
问题 I would like to daemonize a python process, and now want to ask if it is good practice to have a daemon running, like a parent process and call another class which opens 10-30 threads. I'm planning on writing a monitoring script for group of servers and would like to check every server every 5 mins, that each server is checked exactly 5minutes. I would like to have it this way ( sort of speak, ps auxf style output ): |monitor-daemon.py \-check-server.py \-check-server.py .... Thank you! 回答1:

实现Linux Daemon 进程

ぐ巨炮叔叔 提交于 2019-12-07 00:38:06
如果我们远程登录了远程的 Linux 服务器,运行了一些耗时较长的任务,如何让命令提交后不受本地关闭终端窗口/网络断开连接的干扰呢? 守护进程 守护进程,也即通常所说的 Daemon 进程,是 Linux 下一种特殊的后台服务进程,它独立于控制终端并且周期性的执行某种任务或者等待处理某些发生的事件。守护进程的名称通常以 “d” 结尾,如 “httpd”、“crond”、“mysqld”等. Redis 可以通过修改配置文件以 Daemon方式运行. 在 Linux 中,由终端登录系统登入系统后会得到一个 shell 进程,这个终端便成为这个 shell 进程的控制终端(Controlling Terminal)。shell 进程启动的其他进程,由于复制了父进程的信息,因此也都同依附于这个控制终端。终端关闭,相应的进程都会自动关闭。守护进程脱离终端的目的,也即是不受终端变化的影响不被终端打断,当然也不想在终端显示执行过程中的信息。 如果不想进程受到用户、终端或其他变化的影响,就必须把它变成守护进程。 实现守护进程 通过一些特殊命令实现 Daemon 进程 nohup 如果想让某一条长时间运行的命令不受终端退出的影响,可以使用nohup命令. The nohup utility invokes utility with its arguments and at this time

【原创】服务器开发之 Daemon 和 Keepalive

旧街凉风 提交于 2019-12-07 00:37:53
由于业务开发需要,需要对数据库代理进行研究,在研究 MySQL Proxy 实现原理的过程中,对一些功能点进行了分析总结。本文主要讲解下 MySQL Proxy 的 daemon 和 keepalive 功能实现原理。 MySQL Proxy 是数据库代理实现中的一种,提供了 MySQL server 与 MySQL client 之间的通信功能。由于 MySQL Proxy 使用的是 MySQL 网络协议,故其可以在不做任何修改的情况下,配合任何符合该协议的且与 MySQL 兼容的客户端一起使用。 在最基本的配置下,MySQL Proxy 仅仅是简单地将自身置于服务器和客户端之间,负责将 query 从客户端传递到服务器,再将来自服务器的应答返回给相应的客户端。在高级配置下,MySQL Proxy 可以用来监视和改变客户端和服务器之间的通信。查询注入(query interception) 功能允许你按需要添加性能分析命令 (profiling) ,且可以通过 Lua 脚本语言对注入的命令进行脚本化控制。 本文不讨论 MySQL Proxy 作为数据库代理在功能上和实践中的优劣,而是着重讲述其源码实现中的两个功能点:daemon 功能和 keepalive 功能。 通过命令行启动 MySQL Proxy 时经常会用到如下两个配置项: --daemon 和 –keepalive

launchd: sleep in GCD managed signal handler

给你一囗甜甜゛ 提交于 2019-12-06 19:36:29
I encounter a strange situation in a launchd managed daemon when I try to sleep in the SIGTERM handler that is managed with Grand Central Dispatch as described here . Everything works fine and I do get a SIGTERM signal handler before receiving a SIGKILL when I do not sleep in the SIGTERM handler. But as soon as I do sleep -- even for extremly short amounts of time like a usleep(1); -- I do not get a SIGTERM handler at all but instead my daemon is SIGKILLed instantly by launchd. Btw I am using EnableTransactions in my plist file and the proper vproc_transaction_begin(3) / vproc_transaction_end

process from pcntl_fork not terminating

梦想与她 提交于 2019-12-06 15:45:38
I am running a web service which involved with daemons by php+apache2. So I tried pcntl_fork function. But there is a question that the child process are not terminating even I used exit(0) in the child process's code which result in a lot of apache2 processes. I'm wondering if there is a way to shutdown those useless apache2 processes? PS: because I'm not very aware of the mechanism of signal, so I tried to make daemon by a single call to a agent script which will exit as soon as the child is created. switch ($_GET['action']){ case "new": $pid = pcntl_fork(); switch ($pid){ case -1: echo