Answer the question
In order to leave comments, you need to log in
Create a daemon in python 2.7?
There is a script that calls norify os on while True:
So here's how to create a daemon that starts when the OS starts. And it works in the background without a terminal and other things. Ie only pokazyvet message?
Answer the question
In order to leave comments, you need to log in
I always use supervisord . Just a great thing, also written in python. Flexible configs, restart on crash. and other goodies.
How to use:
1) Install it system-wide sudo apt-get install supervisor (you can install it via pip, but you will need to configure more).
2) You need to configure the supervisor itself: where will it get the configs from, what rights are needed, etc. If you have ubuntu, then the settings of the supervisor itself will be in order. They are stored in /etc/supervisor/supervisord.conf. This file says that the settings for the daemons will be read from the /etc/supervisor/conf.d folder.
If you do not have ubuntu, or you installed the supervisor via pip, then here is the standard config. The settings are obvious.
3) When the supervisor is installed and configured, run it:
sudo service supervisor start
или
sudo supervisord
[program:ОТОБРАЖАЕМОЕ_ИМЯ]
command = КОМАНДА_ДЛЯ_ЗАПУСКА (например python ИМЯ_СКРИПТА)
autorestart = true # автостарт при запуске супервизора
stderr_logfile = /var/log/ИМЯ_ЛОГФАЙЛА.err.log # тут перенаправляем stderr в файл
stdout_logfile = /dev/null # тут глушим весь вывод со stdout
supervisorctl reread
supervisorctl ОТОБРАЖАЕМОЕ_ИМЯ start
> And it works in the background without a terminal and other things. Ie only pokazyvet message?
Excuse me, but where will he show you the message? Only if you write to the log.
Or are you displaying information in X?
In any case, here's how to write daemons
stackoverflow.com/questions/473620/how-do-you-crea...
habrahabr.ru/post/176067
To run at system startup, you need to write a script to start your program. In theory, you can also play a demon on bash. If you are interested in this option, I will give an example script.
What is the script written in?
If on the bash, then add & at the end and throw it into autoload. The script will run in the background as a daemon.
For example something like this https://github.com/serverdensity/python-daemon/blo...
In my opinion, the ideal implementation is:
web.archive.org/web/20131017130434/http://www.jeji...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question