Browse Source

production environment with supervisor and crontab

Matej Cotman 11 years ago
parent
commit
8210fe90ea
5 changed files with 71 additions and 6 deletions
  1. 1
    0
      .gitignore
  2. 7
    3
      Makefile
  3. 27
    3
      README.md
  4. 17
    0
      minimal.cfg
  5. 19
    0
      production.cfg

+ 1
- 0
.gitignore View File

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

+ 7
- 3
Makefile View File

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

+ 27
- 3
README.md View File

@@ -7,6 +7,7 @@ List of [running instances](https://github.com/asciimoo/searx/wiki/Searx-instanc
7 7
 
8 8
 [![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)
9 9
 
10
+
10 11
 ### Features
11 12
 
12 13
 * Tracking free
@@ -19,6 +20,7 @@ List of [running instances](https://github.com/asciimoo/searx/wiki/Searx-instanc
19 20
 * Opensearch support (you can set as default search engine)
20 21
 * Configurable search engines/categories
21 22
 
23
+
22 24
 ### Installation
23 25
 
24 26
 * 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
29 31
 
30 32
 For all the details, follow this [step by step installation](https://github.com/asciimoo/searx/wiki/Installation)
31 33
 
34
+
32 35
 ### Alternative (Recommended) Installation
33 36
 
34 37
 * 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/
38 41
 
39 42
 ### Development
40 43
 
41
-Just run `make`. Versions of dependencies are pinned down inside `versions.cfg` to produce most stable build.
44
+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`
45
+
46
+
47
+### Deployment
48
+
49
+* clone source: `git clone git@github.com:asciimoo/searx.git && cd searx`
50
+* build in current folder: `make production`
51
+* run `bin/supervisord` to start the application
42 52
 
43
-#### Command make
53
+
54
+### Upgrading
55
+
56
+* inside previously cloned searx directory run: `git stash` to temporarily save any changes you have made
57
+* pull source: `git pull origin master`
58
+* re-build in current folder: `make production`
59
+* run `bin/supervisorctl stop searx` to stop searx, if it does not, then run `fuser -k 8888/tcp`
60
+* run `bin/supervisorctl reload` to re-read supervisor config and start searx
61
+
62
+
63
+### Command make
44 64
 
45 65
 ##### `make`
46 66
 
@@ -62,9 +82,13 @@ Runs robot (Selenium) tests, you must have `firefox` installed because this func
62 82
 
63 83
 Checks coverage of tests, after running this, execute this: `firefox ./coverage/index.html`
64 84
 
85
+##### `make production`
86
+
87
+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.
88
+
65 89
 ##### `make minimal`
66 90
 
67
-Used to make co-called production environment - without tests (you should ran tests before deploying searx on the server).
91
+Minimal build - without test frameworks, the quickest build option.
68 92
 
69 93
 ##### `make clean`
70 94
 

+ 17
- 0
minimal.cfg View File

@@ -0,0 +1,17 @@
1
+[buildout]
2
+extends = base.cfg
3
+develop = .
4
+
5
+eggs =
6
+    searx
7
+
8
+parts +=
9
+    pyscripts
10
+
11
+
12
+[pyscripts]
13
+recipe = zc.recipe.egg:script
14
+eggs = ${buildout:eggs}
15
+interpreter = py
16
+entry-points =
17
+    searx-run=searx.webapp:run

+ 19
- 0
production.cfg View File

@@ -7,6 +7,8 @@ eggs =
7 7
 
8 8
 parts +=
9 9
     pyscripts
10
+    supervisor
11
+    crontab_reboot
10 12
 
11 13
 
12 14
 [pyscripts]
@@ -15,3 +17,20 @@ eggs = ${buildout:eggs}
15 17
 interpreter = py
16 18
 entry-points =
17 19
     searx-run=searx.webapp:run
20
+
21
+
22
+[supervisor]
23
+recipe = collective.recipe.supervisor
24
+http-socket = unix
25
+user = searxer
26
+password = ohpleasedochangeme
27
+file = /tmp/supervisor.sock
28
+chmod = 0700
29
+programs =
30
+    50 searx    ${buildout:bin-directory}/searx-run
31
+
32
+
33
+[crontab_reboot]
34
+recipe = z3c.recipe.usercrontab
35
+times = @reboot
36
+command = ${buildout:bin-directory}/supervisord