anystack-sh / porter

Spin up your development background processes with ease 🪄
https://anystack.sh/tools/porter
535 stars 11 forks source link

Porter cannot start services, thinks they are already running #29

Open manavo opened 1 year ago

manavo commented 1 year ago

I'm having an issue where the services aren't running, Porter thinks they aren't running, but then can't start them because it thinks they are running.

manavo@MacBook-Pro ~ % porter status

 Porter must be running to use this command. Do you want to start Porter? (yes/no) [yes]:
 > yes

In SupervisordRepository.php line 120:

  Services are already running.  

Not sure if there are any other debug things that would be useful? In the ~/.porter directory this is what I see:

manavo@MacBook-Pro .porter % ls -la
total 56
drwx------   9 manavo  staff   288 12 Jun 14:32 .
drwxr-xr-x+ 76 manavo  staff  2432  6 Jul 16:07 ..
-rw-r--r--   1 manavo  staff    95 26 May 10:39 apps.json
-rw-r--r--   1 manavo  staff   213 26 May 10:33 file-watcher.js
drwx------   2 manavo  staff    64 28 Jun 11:51 logs
srwx------   1 manavo  staff     0 12 Jun 14:32 supervisor.sock
-rw-r--r--   1 manavo  staff  2695  6 Jul 16:08 supervisord.conf
-rw-r--r--   1 manavo  staff  8902 18 Jun 13:41 supervisord.log
-rw-r--r--   1 manavo  staff     6 12 Jun 14:32 supervisord.pid

Not sure if maybe a pid/sock file is somehow leftover, and it's confusing things thinking they are running?

Last note, this is using Porter v0.0.11

manavo commented 1 year ago

Dug into this a little bit, and it seems like that was the case, the .pid file was leftover.

So after running this, it's been able to start the services again:

manavo@MacBook-Pro ~ % mv .porter/supervisord.pid .porter/supervisord.pid.bak
manavo@MacBook-Pro ~ % porter start
Starting services: loading...Unlinking stale socket /Users/manavo/.porter/supervisor.sock
Starting services: ✔

Not sure what caused the .pid file to get left behind though 😕

beNjiox commented 1 year ago

Thanks @manavo - just ran into this issue as well, and your tip worked for me.

Cipfahim commented 1 year ago

Thank you @manavo it worked :) Any idea why this happened?

manavo commented 1 year ago

Not sure, I'm guessing something crashes and the file gets left behind? It hasn't happened to me again, but glad this worked for you!

squatto commented 1 year ago

Rather than having to manually delete the supervisord.pid file, you can instead run this command to have Porter delete it for you:

porter stop --force

For reference...

The stop command calls SupervisordRepository->stopSupervisord() with the force option:

https://github.com/anystack-sh/porter/blob/5a76962cfaf74c97560aeba7a55862f5080a8ab1/app/Commands/StopCommand.php#L31-L33

SupervisordRepository->stopSupervisord() deletes the supervisord.pid file when the force option is provided:

https://github.com/anystack-sh/porter/blob/5a76962cfaf74c97560aeba7a55862f5080a8ab1/app/Repositories/SupervisordRepository.php#L152-L154

manavo commented 1 year ago

Well spotted @squatto! Definitely a better option!

justRau commented 11 months ago

Encountered the same issue when porter was running and did a system reboot.

RobertCordes commented 7 months ago

Just had the same issue. Thank @squatto for mentioning the command.

Wulfheart commented 1 month ago

It works with porter stop --force but I actually don't like it. I found out that it only occurs when I turned of my PC while porter was still running. Is there a way to fix this?