Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Be able to shutdown/restart app from web interface #41
Documentation is to be avoided at all costs. Assume documentation will never be read :)
Make it obvious in the app.
I've read one book so now I'm an expert! (http://www.amazon.com/Design-Everyday-Things-Donald-Norman/dp/0465067107)
I use several apps that has the feature. It's nice.
added a commit
Nov 24, 2012
It's more a question of whether it's realistic than whether it's possible. Genghis runs as:
Of all of these, the only one where an in-browser restart could both be supported and make sense is the last one, and then, only if it's not running under Windows because Windows has
And to top that all off, the "restart" would need to be supported by forking just after daemonizing, but before loading and starting the Sinatra app, and keeping both the parent and child thread around so when the child receives a "restart" command it could send a HUP to its parent which would then spawn off a new child process with the new code, and really what it comes down to is that one spot where it should all be supported is a different project and you ought to go ask them to add restart support ;)
I'm not sure what the difference between realistic and possible in this context is. Regardless, could the restart not simply be a system call which does:
Here's how sickbeard, a python app handles it:
def saveAndShutdown(restart=False): halt() saveAll() logger.log(u"Killing cherrypy") cherrypy.engine.exit() if CREATEPID: logger.log(u"Removing pidfile " + str(PIDFILE)) os.remove(PIDFILE) if restart: install_type = versionCheckScheduler.action.install_type popen_list =  if install_type in ('git', 'source'): popen_list = [sys.executable, MY_FULLNAME] elif install_type == 'win': if hasattr(sys, 'frozen'): # c:\dir\to\updater.exe 12345 c:\dir\to\sickbeard.exe popen_list = [os.path.join(PROG_DIR, 'updater.exe'), str(PID), sys.executable] else: logger.log(u"Unknown SB launch method, please file a bug report about this", logger. ERROR) popen_list = [sys.executable, os.path.join(PROG_DIR, 'updater.py'), str(PID), sys.executable, MY_FULLNAME ] if popen_list: popen_list += MY_ARGS if '--nolaunch' not in popen_list: popen_list += ['--nolaunch'] logger.log(u"Restarting Sick Beard with " + str(popen_list)) subprocess.Popen(popen_list, cwd=os.getcwd()) os._exit(0)
Here's how Unicorn (a ruby webserver) handles it: https://github.com/defunkt/unicorn/blob/master/lib/unicorn/http_server.rb#L400-L455
It is possible to do this, but the functionality really belongs in Vegas, the library Genghis uses to run "as an app". Genghis doesn't have access to the pid, it doesn't know what command line arguments it was called with. From Genghis' point of view, it's just running as a sinatra app. All the details like this are handled by Vegas.
I did not. I'll re-open this issue so I remember to when I get a minute, or you can feel free to do it :)
The proper answer is probably for Vegas to trap SIGHUP and reload its configuration. Then a running process (e.g. Genghis) could signal this:
Process.kill 'HUP', Process.pid