porter icon indicating copy to clipboard operation
porter copied to clipboard

Porter cannot start services, thinks they are already running

Open manavo opened this issue 1 year ago • 9 comments

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 avatar Jul 06 '23 15:07 manavo

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 😕

manavo avatar Jul 06 '23 15:07 manavo

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

beNjiox avatar Jul 10 '23 16:07 beNjiox

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

Cipfahim avatar Aug 26 '23 06:08 Cipfahim

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!

manavo avatar Aug 26 '23 13:08 manavo

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

squatto avatar Oct 25 '23 23:10 squatto

Well spotted @squatto! Definitely a better option!

manavo avatar Oct 26 '23 09:10 manavo

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

justRau avatar Dec 13 '23 07:12 justRau

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

RobertCordes avatar Apr 13 '24 19:04 RobertCordes

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?

Wulfheart avatar Sep 17 '24 09:09 Wulfheart