Демоны для SystemD

6 years 3 months ago - 6 years 3 months ago #2025 by aftertime
aftertime created the topic: Демоны для SystemD
Добрый день!
Спасибо за прекрасный продукт. Поддержал вчера, чем смог.
Единственное, чего не хватает - так это возможности запускать процессы в виде демонов.
Набросал, в меру своего разумения и, на основе старых с форума, свои версии демонов.
Знаю, что такой вопрос поднимался, но около года назад, когда архитектура программы была другой, потому решил не поднимать старую тему, а создать новую.
Сканер:
sopds_scanner.service
Warning: Spoiler! [ Click to expand ]


Веб сервер: sopds_server.service
Warning: Spoiler! [ Click to expand ]


Файлы нужно положить в папку /etc/systemd/system/ Затем каждый установить и проверить статус
systemctl enable sopds_scanner.service
systemctl -l status sopds_scanner.service
systemctl enable sopds_server.service
systemctl -l status sopds_server.service
Last Edit: 6 years 3 months ago by aftertime.

Please Войти or Create an account to join the conversation.

  • aftertime
  • aftertime's Avatar Topic Author
  • Offline
  • Новый участник
  • Новый участник
More
6 years 3 months ago #2026 by aftertime
aftertime replied the topic: Демоны для SystemD
Мне не удалось сделать атк, чтобы демоны работали. Выдают такое сообщение:
root@server:/opt/sopds# systemctl -l status sopds_scanner
● sopds_scanner.service - SOPDS scanner service
   Loaded: loaded (/etc/systemd/system/sopds_scanner.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Вт 2018-01-09 21:03:43 MSK; 21s ago
 Main PID: 2372 (code=exited, status=203/EXEC)
   CGroup: /system.slice/sopds_scanner.service

янв 09 21:03:43 server systemd[1]: sopds_scanner.service: Failed with result 'exit-code'.
root@server:/opt/sopds# systemctl -l status sopds_server
● sopds_server.service - SOPDS WEB Server
   Loaded: loaded (/etc/systemd/system/sopds_server.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Вт 2018-01-09 21:03:24 MSK; 1min 12s ago
 Main PID: 2305 (code=exited, status=203/EXEC)
   CGroup: /system.slice/sopds_server.service
Помогите разобраться. Версия SOPDS 0.44

Please Войти or Create an account to join the conversation.

  • aftertime
  • aftertime's Avatar Topic Author
  • Offline
  • Новый участник
  • Новый участник
More
6 years 1 month ago - 6 years 1 month ago #2086 by bravo123
bravo123 replied the topic: Демоны для SystemD
(code=exited, status=203/EXEC)
Сдаётся что тут дело в том что в manage.py первой строкой идёт :
#!/usr/bin/env python
и по умолчанию, в зависимости от настроек системы у вас запустится Python 2.7, а для запуска демона нужен Python 3.3.Х
следовательно надо либо явно указывать python3 /opt/sopds/manage.py sopds_server start --daemon
либо в manage.py поправить на #!/usr/bin/env python3
Last Edit: 6 years 1 month ago by bravo123.

Please Войти or Create an account to join the conversation.

  • bravo123
  • bravo123's Avatar
  • Offline
  • Осваиваюсь на форуме
  • Осваиваюсь на форуме
More
6 years 2 weeks ago #2104 by bincher
bincher replied the topic: Демоны для SystemD
Тоже не получилось запустить демон.
Пишет
Executable path is not absolute, ignoring
.

Please Войти or Create an account to join the conversation.

  • bincher
  • bincher's Avatar
  • Offline
  • Новый участник
  • Новый участник
More
5 years 10 months ago - 5 years 10 months ago #2111 by Honey12345
Honey12345 replied the topic: Демоны для SystemD

File Attachment:

File Name: SOPDS.zip
File Size:1 KB
Установил последнюю версию SOPDS на последний релиз openmediavault (Debian 9). По инструкции все встало нормально, а вот с автозагрузкой возникли траблы. приведенные ту демоны не завелись. Я поменял в файле manage.py среду выполнения на:
#!/usr/bin/env python3
, но демон sopds_server.service не стартует даже вручную. при старте он тупо не запускается и уходит в рестарт, главно и в логах нет ничего толкового.
root@OMV4:/etc/systemd/system# systemctl start sopds_server.service
root@OMV4:/etc/systemd/system# systemctl status sopds_server.service
● sopds_server.service - SOPDS WEB Server
   Loaded: loaded (/etc/systemd/system/sopds_server.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) since Mon 2018-05-28 07:11:24 +10; 3s ago
  Process: 18666 ExecStop=/opt/sopds/manage.py sopds_server stop --daemon (code=exited, status=0/SUCCESS)
  Process: 18663 ExecStart=/opt/sopds/manage.py sopds_server start --daemon (code=exited, status=0/SUCCESS)
 Main PID: 18663 (code=exited, status=0/SUCCESS)
root@OMV4:/etc/systemd/system# 
. Решил проблему через rc.local. Создаем файл /etc/rc.local следующуго содержания
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sleep 5
/opt/sopds/manage.py sopds_server start --daemon
/opt/sopds/manage.py sopds_scanner start --daemon
/opt/sopds/manage.py sopds_scanner scan

exit 0
Делаем его исполняемым выполнив команды
touch /etc/rc.local
chmod +x /etc/rc.local
. Далее создаем файл /etc/systemd/system/rc-local.service следующего содержания
[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local
 
[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99
 
[Install]
 WantedBy=multi-user.target
Включаем сервис rc-local
systemctl enable rc-local
Запускаем сервис rc-local
systemctl start rc-local.service
Проверяем статус сервиса
root@OMV4:/etc# systemctl start rc-local.service
root@OMV4:/etc# systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (running) since Mon 2018-05-28 07:26:29 +10; 9s ago
  Process: 19100 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/rc-local.service
           ├─19106 python3 /opt/sopds/manage.py sopds_server start --daemon
           └─19110 python3 /opt/sopds/manage.py sopds_scanner start --daemon

май 28 07:26:23 OMV4 systemd[1]: Starting /etc/rc.local Compatibility...
май 28 07:26:29 OMV4 rc.local[19100]: Startup once book-scan.
май 28 07:26:29 OMV4 rc.local[19100]: Complete book-scan.
май 28 07:26:29 OMV4 systemd[1]: Started /etc/rc.local Compatibility.
root@OMV4:/etc# 
У меня в /etc/rc.local стоит задержка 5 сек., это для моей системы, так как при автозагрузке в моей системе rc.local запускается непосредственно после mysql, а mysql еще не успела полностью инициализироваться и при попытке подключения sopds_server к базе вылетала ошибка. Возможно Вам и ненужна эта задержка, можно ее смело убрать. Надеюсь комуто помог.
Attachments:
Last Edit: 5 years 10 months ago by Honey12345. Reason: прикрепил файлы

Please Войти or Create an account to join the conversation.

  • Honey12345
  • Honey12345's Avatar
  • Offline
  • Новый участник
  • Новый участник
More
4 years 8 months ago #2192 by nesmit
nesmit replied the topic: Демоны для SystemD
Из под ользователя нормально стартует, а демоном не хочет. хотя и пишет что успешно.

systemctl -l status sopds_server.service
● sopds_server.service - SOPDS WEB Server
Loaded: loaded (/lib/systemd/system/sopds_server.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) since Mon 2019-08-19 16:14:33 MSK; 1min 32s ago
Process: 2364 ExecStart=/usr/bin/python3 /opt/sopds/manage.py sopds_server start --daemon (code=exited, status=0/SUCCESS)
Process: 2379 ExecStop=/usr/bin/python3 /opt/sopds/manage.py sopds_server stop --daemon (code=exited, status=0/SUCCESS)
Main PID: 2364 (code=exited, status=0/SUCCESS)

Please Войти or Create an account to join the conversation.

  • nesmit
  • nesmit's Avatar
  • Offline
  • Новый участник
  • Новый участник
More
Time to create page: 0.164 seconds