postal icon indicating copy to clipboard operation
postal copied to clipboard

Procodile issue

Open iammattmartin opened this issue 9 years ago • 15 comments

Since the lastest upgrade, any start/stop comamnds generate a nasty error.

/var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/control_client.rb:8:in initialize': Permission denied - connect(2) for /opt/postal/app/tmp/pids/procodile.sock (Errno::EACCES) from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/control_client.rb:8:in new' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/control_client.rb:8:in initialize' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/control_client.rb:19:in new' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/control_client.rb:19:in run' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/cli.rb:140:in start' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/cli.rb:39:in public_send' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/lib/procodile/cli.rb:39:in dispatch' from /var/lib/gems/2.3.0/gems/procodile-1.0.16/bin/procodile:93:in <top (required)>' from /usr/local/bin/procodile:22:in load' from /usr/local/bin/procodile:22:in `

'

I'm unsure how an upgrade could cause this or that it was done before but only surfaced when trying to restart now.

iammattmartin avatar May 12 '17 14:05 iammattmartin

You'll need to check who the process is running as. It sounds like the user you're running your command as doesn't have access to use the socket that controls the processes.

adamcooke avatar May 12 '17 14:05 adamcooke

Not entirely sure. Looking at the user postal and the root user, have always run the postal upgrade comment via the root user without issue until recently.

procodile seems to run as root too.

root 3033 0.0 0.5 683384 11796 ? Sl 15:09 0:00 [procodile] Postal (/opt/postal/app)

postal too.

root 3033 0.0 0.5 683384 11796 ? Sl 15:09 0:00 [procodile] Postal (/opt/postal/app) root 3041 0.1 6.5 853124 133228 ? Sl 15:09 0:11 [postal] web.1 root 3043 0.0 5.9 903768 120724 ? Sl 15:09 0:08 [postal] fast.1 root 3049 0.3 9.9 550712 202584 ? Sl 15:09 0:27 [postal] worker.1 root 3052 0.3 8.1 529688 166896 ? Sl 15:09 0:30 [postal] worker.2 root 3059 0.1 4.9 366044 101820 ? Sl 15:09 0:15 [postal] cron.1 root 3064 0.2 6.1 392680 124360 ? Sl 15:09 0:21 [postal] smtp.1 root 3066 0.1 5.4 375972 111696 ? Sl 15:09 0:09 [postal] requeuer.1

iammattmartin avatar May 12 '17 16:05 iammattmartin

As you say, it's all running as root. That's not right. The postal command is supposed to sudo before it runs anything. Can you stop everything and try starting it again?

adamcooke avatar May 12 '17 18:05 adamcooke

Even running the stop command gives me the error output. Very strange.

I may just re-do the install just in case something unexpected has happened somewhere with the current guide and see what occurs. Always the odd ones. :)

iammattmartin avatar May 12 '17 18:05 iammattmartin

If you send a SIGINT to the main process [procodile] Postal (/opt/postal/app) it should stop everything.

sudo kill -INT 3033

adamcooke avatar May 12 '17 18:05 adamcooke

Odd that did work but need to work out why it is spawning as root instead of postal.

iammattmartin avatar May 15 '17 00:05 iammattmartin

Did you ever find anything else about this? If not, can we close this issue? I've not seen this before nor seen any other similar issues. Is it possible you started postal as root to overcome the issue with listening on the privileged ports?

adamcooke avatar May 16 '17 13:05 adamcooke

Nope.

It starts up as it was doing before but we're still using the 2525/5010/5011 ports as per the original install.

If I kill procodile process, I can do the normal postal start and other commands but do have to manually kill it.

iammattmartin avatar May 16 '17 14:05 iammattmartin

Do you have a full process list for everything with the name postal in it?

adamcooke avatar May 16 '17 14:05 adamcooke

Similar output to before it seems but all still running as root so it appears to not be sudo'ing at all.

I can't spot any config where that can be changed so not sure if it is hard set in the code?

iammattmartin avatar May 16 '17 14:05 iammattmartin

The postal script detects where it is being executed from and sudos based on this. Like this:

# If we're executing from /usr then we should update the root directory
# to our default installation path and we should be allowed to sudo.
if [ $ROOT_DIR == "/usr" ]; then
  SHOULD_SUDO="yes"
  ROOT_DIR=/opt/postal/app
else
  SHOULD_SUDO="no"
fi

If you aren't executing postal through bash you could well find there is no sudoing and you'd need to manually run sudo -u postal before it. The same applies to any sort of systemd script. These should handle starting it for you.

adamcooke avatar May 16 '17 14:05 adamcooke

Worked it out.

Was starting postal in the rc.local as it had no startup script originally - that was the cause.

I'll alter that to be a bit more effective as it does not pick up the user env it seems and thus does not sudo.

Will close and ref #125 on this.

iammattmartin avatar May 16 '17 14:05 iammattmartin

Great. Just popping a sudo -u postal in front of it in rc.local should work.

adamcooke avatar May 16 '17 14:05 adamcooke

Exactly what I was thinking. 👍

iammattmartin avatar May 16 '17 14:05 iammattmartin

rc.local

change postal start exit 0 to su postal -c 'postal start' exit 0

Then it all works :-)

blakilox avatar Aug 20 '18 21:08 blakilox