I am running a server with MKDocs for documentation.
In order to use the MKDocs from the directory where the project is you need to run mkdocs serve -a 192.168.3.107:8080
in order to get it to start.
So far I was using /usr/bin/tmux new-session -d -s "MKDOCS" "cd /root/mkdocs && mkdocs serve -a 192.168.3.107:8080"
to have it run in the background but this is a very sketchy solution and I would like to run it as systemd Service.
I was trying something like this but it doesn't work:
[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
After I run the service with start, the status shows :
root@server:~/mkdocs
● 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)
I get journalctl -xe shows:
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
Feb 02 13:54:44 server.domain.local systemd[1]: mkdocs.service: Main process exited, code=exited, status=203/EXEC
Feb 02 13:54:44 server.domain.local systemd[1]: mkdocs.service: Failed with result 'exit-code'.
I have given the directory full permissions with chmod -R 777 /root/mkdocs
however I still get the same error.
Hopefully, someone can help me get it working. Thank you
EDIT:
I have Changed the path, still will 777 permissions, so the code now is:
however it still doesn't work, I am getting :
root@server:/test
root@server:/test
root@server:/test
● 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'.
and journalctl -xe
shows:
Feb 02 14:20:32 server.domain.local systemd[1]: Started mkdocs service.
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
Feb 02 14:20:32 server.domainlocal systemd[1]: mkdocs.service: Main process exited, code=exited, status=203/EXEC
Feb 02 14:20:32 server.domain.local systemd[1]: mkdocs.service: Failed with result 'exit-code'.
it doesn't make any sense since the permissions are 777.