Giter Site home page Giter Site logo

Comments (5)

kingosticks avatar kingosticks commented on September 25, 2024

I think when we played around before with having it restart itself it
didn't work. Presumably because when you stop you obviously then can't
start again! So you need to do the restart from another process. I think.
On 22 Nov 2015 04:37, "John Cass" [email protected] wrote:

It may be useful to have an option available to restart the Mopidy service
to deal with situations where the actor dies unexpectedly (e.g. due to a
misbehaving backend extension).

This would be quicker than having to do a full reboot, and easier than
having to log in to the terminal to issue the command manually.

It probably means just adding WebServiceRestartRequestHandler that does service
mopidy restart, similar to

class WebRebootRequestHandler(tornado.web.RequestHandler):
def initialize(self, core):
self.core = core
def post(self):
logger.info('Halting system')
os.system("sudo shutdown -r now")
os.system("shutdown -r now")

?


Reply to this email directly or view it on GitHub
#17.

from mopidy-websettings.

kingosticks avatar kingosticks commented on September 25, 2024

And in musicbox we have a process manager to restart mopidy (and other
things) if/when they crash. The name of it escapes me.
On 22 Nov 2015 13:11, "Nick Steel" [email protected] wrote:

I think when we played around before with having it restart itself it
didn't work. Presumably because when you stop you obviously then can't
start again! So you need to do the restart from another process. I think.
On 22 Nov 2015 04:37, "John Cass" [email protected] wrote:

It may be useful to have an option available to restart the Mopidy
service to deal with situations where the actor dies unexpectedly (e.g. due
to a misbehaving backend extension).

This would be quicker than having to do a full reboot, and easier than
having to log in to the terminal to issue the command manually.

It probably means just adding WebServiceRestartRequestHandler that does service
mopidy restart, similar to

class WebRebootRequestHandler(tornado.web.RequestHandler):
def initialize(self, core):
self.core = core
def post(self):
logger.info('Halting system')
os.system("sudo shutdown -r now")
os.system("shutdown -r now")

?


Reply to this email directly or view it on GitHub
#17.

from mopidy-websettings.

jcass77 avatar jcass77 commented on September 25, 2024

Yes you may be thinking of monit.

The problem is that the Mopidy actor may be dead even though Mopidy itself keeps on responding on port 6680 (which is what monit checks for). This means that if an internal Mopidy error occurs that causes certain extensions to stop working monit will not always pick up on it.

I haven't been able to figure out how to get the service to restart itself though. Simply spawning a separate process to run the os command does not appear to be sufficient as the SIGTERM signal is propagated to all subprocesses, which means they all die when the main process goes down.

from mopidy-websettings.

kingosticks avatar kingosticks commented on September 25, 2024

That is a good point.

You can probably send a command to monit and have it do the restart but that's not very helpful if you don't have monit running.

Simply spawning a separate process to run the os command does not appear to be sufficient as the SIGTERM signal is propagated to all subprocesses, which means they all die when the main process goes down.

I think it needs to be a different process group to stop this happening. Or maybe just use python-daemon?

from mopidy-websettings.

jcass77 avatar jcass77 commented on September 25, 2024

I'm not getting anywhere with this. I tried creating a temporary shell script that ignores SIGTERM and creates a subprocess from within the script:

script = '''#!/bin/sh
python -c 'import subprocess, signal\nsignal.signal(signal.SIGTERM, signal.SIG_IGN)\nsubprocess.Popen(["service", "mopidy", "restart"])'
'''
script_file = tempfile.NamedTemporaryFile('wt')
script_file.write(script)
script_file.flush()

subprocess.call(["sh", script_file.name], close_fds=True)

This, and everything else I've tried, just dies along with the main mopidy process.

Messing with the process groups and dealing with sessions and orphans seems pretty complicated (http://linux.die.net/man/2/setpgid).

Does anybody have any code examples that we could perhaps use as a baseline?

from mopidy-websettings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.