-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daemon/Init/Start/Stop to keep brewpi script alive #16
Comments
The brewpi service can be started/stopped. Who should be able to start/restart brewpi? We need to stop/restart BrewPi for updates Developers need to be able to prevent brewpi from restarting automatically. (eg. sudo service brewpi stop) Multiple conflicting instances of brewpi should be prevented. Perhaps take into account future implementation of brewpi: In the future, we are likely to ditch apache and to integrate the webserver into python. BrewPi will consists of two (or 3) python scripts, of which the webserver is always running. A likely implementation is that each Arduino is wrapped by a driver script. Another process communicates with these drivers. The data logger could be a separate process as well. |
asked a couple sys admins what they thought, they recommended daemontools: http://cr.yp.to/daemontools.html might be worth trying to compile for the pi, author declares it public domain: -b |
Daemontools is definitely a solid program, but it requires another install process for the user to perform. Great for a sysadmin, but tough to distribute What comments do you have on the requirements? |
I was thinking about root/brewpi/www-data. Starting/stopping daemons might need root access. If we decide to have a script always running, it does not really matter. It can be stopped in ssh with sudo. I think splitting this in a script that manages what runs and the actual program might be the most flexible way forward. This script could read lock files and start the application script (perhaps with start-stop-daemon). Running a separate script as a watchdog gives us more freedom than using inittab on the application script directly. We could even have a windows and mac alternative for this script. daemontools is on apt-get, so why would it be a problem? |
We keep shooting to discussing solutions, before we fully understand the problem. Got your rationale on user access levels, but we can we flesh out if we really ever need to stop the script? |
Here are a couple of reasons that the script should be able to be stopped:
It's also bad form to not provide an easy way to stop a daemon. |
I agree with Robbert here. If we choose not to stop the script through the web interface (which is simple, but should be omitted when we don't have a way to start it through the web interface probably, which is not simple). I think the requirements can be simplified:
So let's get this out of the way first: do we want to get rid of the ability to start/stop the script from the web interface? |
I think the requirements Elco listed are reasonable and that there isn't a need to be able to start/stop the script from the web interface. Anybody doing the type of maintenance (or anything else) where they would want to stop the script would most likely have sudo access. |
I postpone this to next release, so we can properly develop this in a feature branch. There has been enough feature creep. This release will be on cron.d with I don't want to stop the discussion here, but let's not hold up the release any longer. |
Temporary fix with cron.d done: |
Just remember, if you release with cron.d, we'll have to add in a check to remove it, should we go a different way in the future ;) |
I know, but it doesn't seem like we will resolve this issue soon. There has
|
looking into supervisord... |
cron job in cron.d works fine for now. In a next version with a new service layer we might reconsider. Issue closed for now. |
Elco, shouldn't this be reopened and put in the backlog? Maybe some new tags for version numbers, and a tag for general backlog. |
Re-opened for discussing running BrewPi as a service. |
daemontools is indeed packaged under aptitude now (boy am I getting old), so that clears the first big hurdle I saw. Additionally, daemontools:
like bswchinn, several admins I spoke with say this is the 'new hotness' and cannot think of anything that another service monitor offers that daemontools does not; but dameontools has it all. Plus, init.d is going away in debian, to be replaced by systemd. I don't know a lot about this, but it seems the community is widely against this. So, that leads to a potential lack of support in the future for either init.d or systemd. |
Per discussion in channel, here's the proposed implementation plan for Daemontools: Install/Upgrade scripts(changes will be made appropriately in each of these scripts to install DT/daemon)
brewpi.pybrewpi.py will be able to issue the stop and (re)start commands, in place of writing the dontrunfile.
?? remove checkrunning.sh ??brewpiProcess.py
brewpi-www
Modules
We could still use cron.d/module.cron for scheduled tasks like this, but we again risk spreading code out all across the OS. Not necessarily a bad thing, but it becomes more cumbersome for us, as software, to track. In summaryThis is my first stab at changes that could be made. I don't know the guts of brewpi as well as others, what other ramifications would there be that need to be thought of? |
This is a summary of what has been discussed in the IRC channel and a list of requirements for starting/restarting brewpi.
The old way of doing things (master)
This starts the script unbuffered (-u) and redirects the output to log files.
Motivation
The web server runs as the www-data user and it should not be able to access/execute anything outside of it's own dir and/or usergroup. Stopping the script is no problem, because brewpi is listening on the socket. To start it, the www-data user can just remove the file and wait for the cron job to restart the script as the brewpi user. This keeps the permissions for the www-data user limited.
The brewpi user is a member of the www-data group, but not the other way around.
Limitations
The main requirements for the daemon are:
Our options so far:
So now we have a place to discuss this properly. I don't know much about this topic, so your opinions are very welcome.
The text was updated successfully, but these errors were encountered: