production environment with supervisor and crontab

This commit is contained in:
Matej Cotman 2014-01-15 21:18:11 +01:00
parent 77bd3e0496
commit 8210fe90ea
5 changed files with 71 additions and 6 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ eggs/
local/ local/
searx.egg-info/ searx.egg-info/
parts/ parts/
var/

View File

@ -37,14 +37,18 @@ coverage: .installed.cfg
@bin/coverage report --show-missing @bin/coverage report --show-missing
@bin/coverage html --directory ./coverage @bin/coverage html --directory ./coverage
minimal: bin/buildout production.cfg setup.py enginescfg production: bin/buildout production.cfg setup.py enginescfg
bin/buildout -c production.cfg $(options) bin/buildout -c production.cfg $(options)
@echo "* Please modify `readlink --canonicalize-missing ./searx/settings.py`" @echo "* Please modify `readlink --canonicalize-missing ./searx/settings.py`"
@echo "* Hint 1: on production, disable debug mode and change secret_key" @echo "* Hint 1: on production, disable debug mode and change secret_key"
@echo "* Hint 2: to run server execute 'bin/searx-run'" @echo "* Hint 2: searx will be executed at server startup by crontab"
@echo "* Hint 3: to run immediatley, execute 'bin/supervisord'"
minimal: bin/buildout minimal.cfg setup.py enginescfg
bin/buildout -c minimal.cfg $(options)
clean: clean:
@rm -rf .installed.cfg .mr.developer.cfg bin parts develop-eggs \ @rm -rf .installed.cfg .mr.developer.cfg bin parts develop-eggs \
searx.egg-info lib include .coverage coverage searx.egg-info lib include .coverage coverage
.PHONY: all tests enginescfg robot flake8 coverage minimal clean .PHONY: all tests enginescfg robot flake8 coverage production minimal clean

View File

@ -7,6 +7,7 @@ List of [running instances](https://github.com/asciimoo/searx/wiki/Searx-instanc
[![Flattr searx](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=asciimoo&url=https://github.com/asciimoo/searx&title=searx&language=&tags=github&category=software) [![Flattr searx](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=asciimoo&url=https://github.com/asciimoo/searx&title=searx&language=&tags=github&category=software)
### Features ### Features
* Tracking free * Tracking free
@ -19,6 +20,7 @@ List of [running instances](https://github.com/asciimoo/searx/wiki/Searx-instanc
* Opensearch support (you can set as default search engine) * Opensearch support (you can set as default search engine)
* Configurable search engines/categories * Configurable search engines/categories
### Installation ### Installation
* clone source: `git clone git@github.com:asciimoo/searx.git && cd searx` * clone source: `git clone git@github.com:asciimoo/searx.git && cd searx`
@ -29,6 +31,7 @@ List of [running instances](https://github.com/asciimoo/searx/wiki/Searx-instanc
For all the details, follow this [step by step installation](https://github.com/asciimoo/searx/wiki/Installation) For all the details, follow this [step by step installation](https://github.com/asciimoo/searx/wiki/Installation)
### Alternative (Recommended) Installation ### Alternative (Recommended) Installation
* clone source: `git clone git@github.com:asciimoo/searx.git && cd searx` * clone source: `git clone git@github.com:asciimoo/searx.git && cd searx`
@ -38,9 +41,26 @@ For all the details, follow this [step by step installation](https://github.com/
### Development ### Development
Just run `make`. Versions of dependencies are pinned down inside `versions.cfg` to produce most stable build. Just run `make`. Versions of dependencies are pinned down inside `versions.cfg` to produce most stable build. Also remember, NO make command should be run as root, not even `make production`
#### Command make
### Deployment
* clone source: `git clone git@github.com:asciimoo/searx.git && cd searx`
* build in current folder: `make production`
* run `bin/supervisord` to start the application
### Upgrading
* inside previously cloned searx directory run: `git stash` to temporarily save any changes you have made
* pull source: `git pull origin master`
* re-build in current folder: `make production`
* run `bin/supervisorctl stop searx` to stop searx, if it does not, then run `fuser -k 8888/tcp`
* run `bin/supervisorctl reload` to re-read supervisor config and start searx
### Command make
##### `make` ##### `make`
@ -62,9 +82,13 @@ Runs robot (Selenium) tests, you must have `firefox` installed because this func
Checks coverage of tests, after running this, execute this: `firefox ./coverage/index.html` Checks coverage of tests, after running this, execute this: `firefox ./coverage/index.html`
##### `make production`
Used to make co-called production environment - without tests (you should ran tests before deploying searx on the server). This installs supervisord, so if searx crashes, it will try to pick itself up again. And crontab entry is added to start supervisord at server boot.
##### `make minimal` ##### `make minimal`
Used to make co-called production environment - without tests (you should ran tests before deploying searx on the server). Minimal build - without test frameworks, the quickest build option.
##### `make clean` ##### `make clean`

17
minimal.cfg Normal file
View File

@ -0,0 +1,17 @@
[buildout]
extends = base.cfg
develop = .
eggs =
searx
parts +=
pyscripts
[pyscripts]
recipe = zc.recipe.egg:script
eggs = ${buildout:eggs}
interpreter = py
entry-points =
searx-run=searx.webapp:run

View File

@ -7,6 +7,8 @@ eggs =
parts += parts +=
pyscripts pyscripts
supervisor
crontab_reboot
[pyscripts] [pyscripts]
@ -15,3 +17,20 @@ eggs = ${buildout:eggs}
interpreter = py interpreter = py
entry-points = entry-points =
searx-run=searx.webapp:run searx-run=searx.webapp:run
[supervisor]
recipe = collective.recipe.supervisor
http-socket = unix
user = searxer
password = ohpleasedochangeme
file = /tmp/supervisor.sock
chmod = 0700
programs =
50 searx ${buildout:bin-directory}/searx-run
[crontab_reboot]
recipe = z3c.recipe.usercrontab
times = @reboot
command = ${buildout:bin-directory}/supervisord