garybowers / iventoy_docker

iVentoy PXE Server in a Docker Container
Apache License 2.0
43 stars 9 forks source link

PXE Autostart #7

Open chrisf4lc0n opened 1 month ago

chrisf4lc0n commented 1 month ago

Would you be able to help me with the PXE autostart? According to the iVentoy documentation bash iventoy.sh -R start could be issued to autostart the PXE. I am trying to incorporate that into my docker-compose.yml with: command: ["/bin/bash", "-c", "/iventoy/ivenoty.sh -R start"] but I get: Error: positional arguments are not supported:

garybowers commented 1 month ago

I think you need to put the "-R" and "start" as separate entries like:

command: ["/bin/bash", "-c", "/iventoy/ivenoty.sh", "-R", "start"]

That being said the supervisor.conf file is missing the start so i'll add that!

`

chrisf4lc0n commented 1 month ago

Hi, It wasn't command: ["/bin/bash", "-c", "/iventoy/ivenoty.sh", "-R", "start"] I am afraid, I still get the Error: positional arguments are not supported. I have also tried adding the environmental variable:

environment:
      - AUTO_START_PXE=true 

but I got this instead:

2024/06/06 16:56:42.001 [PXE]  iVentoy entering main loop ...

2024-06-06 16:56:42,309 INFO spawned: 'iventoy' with pid 33

2024/06/06 16:56:42.330 [PXE]  flock file </var/run/iventoy.pid> failed errno:11.

2024/06/06 16:56:42.331 [PXE]  Failed to lock file /var/run/iventoy.pid.

2024/06/06 16:56:42.331 [PXE]  Failed to set daemon mode.

2024/06/06 16:56:42.331 [PXE]  ### iVentoy start failed. ###

2024-06-06 16:56:42,331 WARN exited: iventoy (exit status 0; not expected)

2024-06-06 16:56:43,333 INFO reaped unknown pid 35 (exit status 235)

2024-06-06 16:56:44,336 INFO spawned: 'iventoy' with pid 36

2024/06/06 16:56:44.342 [PXE]  flock file </var/run/iventoy.pid> failed errno:11.

2024/06/06 16:56:44.342 [PXE]  Failed to lock file /var/run/iventoy.pid.

2024/06/06 16:56:44.342 [PXE]  Failed to set daemon mode.

2024/06/06 16:56:44.342 [PXE]  ### iVentoy start failed. ###

2024-06-06 16:56:44,342 WARN exited: iventoy (exit status 0; not expected)

2024-06-06 16:56:45,343 INFO reaped unknown pid 38 (exit status 235)

2024-06-06 16:56:47,346 INFO spawned: 'iventoy' with pid 39

2024/06/06 16:56:47.351 [PXE]  flock file </var/run/iventoy.pid> failed errno:11.

2024/06/06 16:56:47.351 [PXE]  Failed to lock file /var/run/iventoy.pid.

2024/06/06 16:56:47.351 [PXE]  Failed to set daemon mode.

2024/06/06 16:56:47.351 [PXE]  ### iVentoy start failed. ###

2024-06-06 16:56:47,351 WARN exited: iventoy (exit status 0; not expected)

2024-06-06 16:56:47,351 INFO reaped unknown pid 41 (exit status 235)

2024-06-06 16:56:48,352 INFO gave up: iventoy entered FATAL state, too many start retries too quickly

Adding the the start to supervisor.conf should indeed solve the issue.

chrisf4lc0n commented 1 month ago

I have done a bit more digging and realised that even setting up supervisor.conf to:

root@iventoy:/# cat /etc/supervisor/supervisord.conf
[supervisord]
nodaemon=true
user=root

[program:iventoy]
directory=/iventoy
command=sh -c 'env IVENTOY_API_ALL=1 env AUTO_START_PXE=true lib/iventoy -A -R start'
startsecs = 30 ;

still throws the error:

2024/06/07 11:32:37.193 [PXE]  flock file </var/run/iventoy.pid> failed errno:11.

2024/06/07 11:32:37.193 [PXE]  Failed to lock file /var/run/iventoy.pid.

2024/06/07 11:32:37.193 [PXE]  Failed to set daemon mode.

2024/06/07 11:32:37.193 [PXE]  ### iVentoy start failed. ###
garybowers commented 1 month ago

Hey yeah I was doing some testing last night and got the same thing, but when you go in the UI and hit the "Play Button" it works, so need to do some debugging what's going on.

chrisf4lc0n commented 1 month ago

I am not a programmer and have I have failed miserably when I tried to dockerize anything. I did experiment with something rather simple but effective though:

root@iventoy:/# cat /var/run/iventoy.pid
9root@iventoy:/# kill -9 9
root@iventoy:/# cd iventoy/
root@iventoy:/iventoy# ./iventoy.sh -R start
iventoy start SUCCESS PID=58

Please open your browser and visit http://127.0.0.1:26000 or http://x.x.x.x:26000 (x.x.x.x is any valid IP address)

It looks like the PID "9" is always the same. This also works:

root@iventoy:/# cat /var/run/iventoy.pid
root@iventoy:/# ./iventoy.sh stop
bash: ./iventoy.sh: No such file or directory
root@iventoy:/# cd iventoy/
root@iventoy:/iventoy# ./iventoy.sh stop
root@iventoy:/iventoy# ./iventoy.sh -R start
iventoy start SUCCESS PID=68

Please open your browser and visit http://127.0.0.1:26000 or http://x.x.x.x:26000 (x.x.x.x is any valid IP address)

I was thinking it could be the issue with the file permissions, but:

root@iventoy:/iventoy# ls -al /var/run/iventoy.pid 
-rw-r--r-- 1 root root 2 Jun  7 13:06 /var/run/iventoy.pid
root@iventoy:/iventoy# id -u
0