sergiotapia / magnetissimo

Web application that indexes all popular torrent sites, and saves it to the local database.
MIT License
3k stars 190 forks source link

phoenix.server occassionally stops #59

Closed Elly6 closed 6 years ago

Elly6 commented 7 years ago

What's the best way to automatically redeploy the phoenix.server when it stops? If I wanted to leave magnetissimo unattended for a prolonged period of time.

trigun0x2 commented 7 years ago

systemd and upstart are both good for Linux. But determining the cause would be better :P

Jeffrey Tong

 / I make companies

tel:1-415-513-6871

This e-mail message may contain confidential or legally privileged information and is intended only for the use of the intended recipient(s). Any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is prohibited. E-mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, or contain viruses. Anyone who communicates with us by e-mail is deemed to have accepted these risks. Jeffrey Tong is not responsible for errors or omissions in this message and denies any responsibility for any damage arising from the use of e-mail. Any opinion and other statement contained in this message and any attachment are solely those of the author and do not necessarily represent those of the company.

On Wed, Feb 01, 2017 at 6:20 PM Elly6

< mailto:Elly6 notifications@github.com

wrote:

a, pre, code, a:link, body { word-wrap: break-word !important; }

What's the best way to automatically redeploy the phoenix.server when it stops? If I wanted to leave magnetissimo unattended for a prolonged period of time.

You are receiving this because you are subscribed to this thread.

Reply to this email directly, https://github.com/sergiotapia/magnetissimo/issues/59 , or https://github.com/notifications/unsubscribe-auth/ADwQUP8oHP_FVofUpiM5L7t7f2s23sFBks5rYRNXgaJpZM4L0hUL .

apexo commented 7 years ago

systemd does not magically help. At least for me, the beam process stays around, even when the server is down.

I'm currently using a script like this:

#!/bin/sh
while true; do
    if curl -s http://localhost:4000 >/dev/null; then
        true
    else
        systemctl restart magnetissimo.service
    fi
    sleep 120
done
apexo commented 7 years ago

… and a systemd unit (/etc/systemd/system/magnetissimo.service) like this:

[Unit]
Description=magnetissimo service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/mix phoenix.server
WorkingDirectory=/home/user/magnetissimo
Restart=always
RestartSec=30s
User=user
Group=user
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
Elly6 commented 7 years ago

@apexo

Thanks! A bash loop makes sense, I'll use your script. Though, I thought phoenix.server might have some options we could pass when deploying the server. (e.g. -p, -r, --persist, --ignore-errors)

I'll leave this issue open a bit longer if anyone has other suggestions.

tchoutri commented 6 years ago

Thanks for the systemd unit, @apexo. May I add it to the deployment documentation?

apexo commented 6 years ago

Yes, of course. Sorry for the late response.

apexo commented 6 years ago

May want to get rid of the "Group=user", it's kind of useless.

tchoutri commented 6 years ago

Thank you very much :)