daemon

Running Python in background on OS X

荒凉一梦 提交于 2019-12-18 10:13:41
问题 Is there any way to keep my Python script (with an endless 'while' loop) running in the background on OS X? Also, for the same purpose, is there any way to have "autorun" python script on a USB drive? 回答1: If you want to have the script running as a daemon process which starts automatically, you can use launchctl and a plist file. For example, Bob has a simple python script which writes the word 'foo' to a file every second in his home directory: #!/usr/bin/env python import os import time

What does the DOCKER_HOST variable do?

不羁的心 提交于 2019-12-18 10:07:46
问题 I'm new to Docker, using Boot2Docker on OSX. After booting it, this message is given: To connect the Docker client to the Docker daemon, please set export DOCKER_HOST=tcp://192.168.59.103:2375 Yet even without it, basic Docker commands (eg, docker run hello-world ) work fine. The install instructions aren't very informative: Note: If you see a message in the terminal that looks something like this: To connect the Docker client to the Docker daemon, please set: export DOCKER_HOST=tcp://192.168

Daemon logging in Linux

回眸只為那壹抹淺笑 提交于 2019-12-18 09:58:51
问题 So I have a daemon running on a Linux system, and I want to have a record of its activities: a log. The question is, what is the "best" way to accomplish this? My first idea is to simply open a file and write to it. FILE* log = fopen("logfile.log", "w"); /* daemon works...needs to write to log */ fprintf(log, "foo%s\n", (char*)bar); /* ...all done, close the file */ fclose(log); Is there anything inherently wrong with logging this way? Is there a better way, such as some framework built into

Run Java AWT/Swing GUI app in headless server

陌路散爱 提交于 2019-12-18 09:16:09
问题 I have a gateway application that comes up with a login dialog and then a GUI window. I will be running this app on a co-located server without a display. I need to interact with the dialog only when logging in and perhaps to check out the main GUI occasionally. The server is Debian 5.0. The only ideas I have so far are: Tunnel an X session to my desktop for logging in but I'm not sure what will happen if the X session disconnected (ie, I reboot my desktop, etc..) Try to instantiate/launch

Daemoninsing a rake task

非 Y 不嫁゛ 提交于 2019-12-18 04:17:12
问题 I have a rake task which runs mailman under the rails environment. I'd like to ensure that rake task is always running via a daemon. My rake task is rake incoming_mail How would I go about daemonising that? 回答1: If you are on linux you could consider using start-stop-daemon. start-stop-daemon -S --pidfile /var/run/incoming_mail.pid -u rails_user -d /path/to/your/rails/app -b -a "rake incoming_mail" To later gracefully kill the process you can use most of the arguments but replace -S with -K.

What would be the simplest way to daemonize a python script in Linux?

天涯浪子 提交于 2019-12-18 01:14:09
问题 What would be the simplest way to daemonize a python script in Linux ? I need that this works with every flavor of Linux, so it should only use python based tools. 回答1: See Stevens and also this lengthy thread on activestate which I found personally to be both mostly incorrect and much to verbose, and I came up with this: from os import fork, setsid, umask, dup2 from sys import stdin, stdout, stderr if fork(): exit(0) umask(0) setsid() if fork(): exit(0) stdout.flush() stderr.flush() si =

Check if key is pressed using python (a daemon in the background)

こ雲淡風輕ζ 提交于 2019-12-17 23:22:42
问题 I've created a python script in which an event needs to be executed each time I press the Super (or WinKey) on my keyboard. How can one achieve this without the python process being "focused" - as it is running in the background waiting for the key to be pressed to execute the event? I've seen a lot of posts around the web showing me how to read input - but they have all required one to have the process "focused" and none have showed me how to capture the Super (or WinKey) using a python

How can I set up Celery to call a custom initialization function before running my tasks?

放肆的年华 提交于 2019-12-17 22:35:47
问题 I have a Django project and I'm trying to use Celery to submit tasks for background processing ( http://ask.github.com/celery/introduction.html ). Celery integrates well with Django and I've been able to submit my custom tasks and get back results. The only problem is that I can't find a sane way of performing custom initialization in the daemon process. I need to call an expensive function that loads a lot of memory before I start processing the tasks, and I can't afford to call that

How to move SimpleSocket server into a background process

时光总嘲笑我的痴心妄想 提交于 2019-12-17 21:13:43
问题 I have a simple socketServer that works perfectly on the main thread. #Server PORT PORT = 8020 #reassign variables Handler = Server #this is a SimpleHTTPHandler httpd = SocketServer.TCPServer(("", PORT), Handler) httpd.serve_forever() I need to have this run in the background and have the ability to stop the process at will. What is the proper way to do this? EDIT Sorry I was unclear. I need to have the server running non stop and I can only access the system from SSH so I can't just start it

Choosing and deploying a comet server

巧了我就是萌 提交于 2019-12-17 17:48:24
问题 I want to push data to the browser over HTTP without killing my django/python application. I decided to use a comet server, to proxy requests between my application and the client (though I still haven't really figured it out properly). I've looked into the following engines: orbited cometd ejabberd jetty Has anyone had any experience working with these servers and deploying them? Any insight and links regarding the topics would be great. Thank you. 回答1: I would recommend looking into Twisted