Я запускаю сервер с MKDocs для документации.
Чтобы использовать MKDocs из каталога, в котором находится проект, вам нужно запустить mkdocs serve -a 192.168.3.107:8080
, чтобы запустить его.
До сих пор я использовал /usr/bin/tmux new-session -d -s "MKDOCS" "cd /root/mkdocs && mkdocs serve -a 192.168.3.107:8080"
, чтобы получить его работать в фоновом режиме, но это очень схематичное решение, и я хотел бы запустить его как службу systemd.
Я пытался что-то вроде этого, но это не сработало:
[Unit]
Description=mkdocs service
ConditionPathExists=/root/mkdocs
[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/bin
ExecStart=/root/mkdocs serve -a 192.168.3.107:8080
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
После того, как я запустил службу с запуском, статус показывает:
root@server:~/mkdocs# service mkdocs status
● mkdocs.service - mkdocs service
Loaded: loaded (/etc/systemd/system/mkdocs.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-02-02 13:54:44 CET; 3min 46s ago
Process: 379585 ExecStart=/root/mkdocs serve -a 192.168.3.107:8080 (code=exited, status=203/EXEC)
Main PID: 379585 (code=exited, status=203/EXEC)
Я получаю journalctl -xe показывает:
-- The job identifier is 368094.
Feb 02 13:54:44 server.domain.local systemd[379585]: mkdocs.service: Failed to execute command: Permission denied
Feb 02 13:54:44 server.domain.local systemd[379585]: mkdocs.service: Failed at step EXEC spawning /root/mkdocs: Permission denied
-- Subject: Process /root/mkdocs could not be executed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The process /root/mkdocs could not be executed and failed.
--
-- The error number returned by this process is ERRNO.
Feb 02 13:54:44 server.domain.local systemd[1]: mkdocs.service: Main process exited, code=exited, status=203/EXEC
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mkdocs.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 203.
Feb 02 13:54:44 server.domain.local systemd[1]: mkdocs.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mkdocs.service has entered the 'failed' state with result 'exit-code'.
Я дал каталог заполнен разрешения с помощью chmod -R 777 /root/mkdocs
, однако я все еще получаю ту же ошибку.
Надеюсь, кто-нибудь поможет мне заставить его работать. Спасибо
РЕДАКТИРОВАТЬ:
Я изменил путь, по-прежнему будут разрешения 777, поэтому теперь код:
, однако он все еще не работает, я получаю:
root@server:/test# systemctl daemon-reload
root@server:/test# systemctl start mkdocs.service
root@server:/test# systemctl status mkdocs.service
● mkdocs.service - mkdocs service
Loaded: loaded (/etc/systemd/system/mkdocs.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-02-02 14:17:24 CET; 4s ago
Process: 380128 ExecStart=/test mkdocs serve -a 192.168.3.107:8080 (code=exited, status=203/EXEC)
Main PID: 380128 (code=exited, status=203/EXEC)
Feb 02 14:17:24 server.domain.local systemd[1]: Started mkdocs service.
Feb 02 14:17:24 server.domain.local systemd[380128]: mkdocs.service: Failed to execute command: Permission denied
Feb 02 14:17:24 server.domain.local systemd[380128]: mkdocs.service: Failed at step EXEC spawning /test: Permission denied
Feb 02 14:17:24 server.domain.local systemd[1]: mkdocs.service: Main process exited, code=exited, status=203/EXEC
Feb 02 14:17:24 server.domain.local systemd[1]: mkdocs.service: Failed with result 'exit-code'.
и journalctl -xe
показывает:
-- The unit mkdocs.service has entered the 'failed' state with result 'exit-code'.
Feb 02 14:20:32 server.domain.local systemd[1]: Started mkdocs service.
-- Subject: A start job for unit mkdocs.service has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mkdocs.service has finished successfully.
--
-- The job identifier is 368972.
Feb 02 14:20:32 server.domain.local systemd[380164]: mkdocs.service: Failed to execute command: Permission denied
Feb 02 14:20:32 server.domain.local systemd[380164]: mkdocs.service: Failed at step EXEC spawning /test: Permission denied
-- Subject: Process /test could not be executed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The process /test could not be executed and failed.
--
-- The error number returned by this process is ERRNO.
Feb 02 14:20:32 server.domainlocal systemd[1]: mkdocs.service: Main process exited, code=exited, status=203/EXEC
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mkdocs.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 203.
Feb 02 14:20:32 server.domain.local systemd[1]: mkdocs.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mkdocs.service has entered the 'failed' state with result 'exit-code'.
это не имеет никакого смысла, так как разрешения 777.