on pycurl help sign in
searx/utils/fabfile.py
117 lines 2.6 kB history raw
1from fabric.api import cd, run, sudo, put
2from cStringIO import StringIO
5base_dir = '/usr/local'
6hostname = 'searx.me'
7searx_dir = base_dir + '/searx'
8searx_ve_dir = searx_dir + '/searx-ve'
9current_user = run('whoami').stdout.strip()
11uwsgi_file = '''
12[uwsgi]
13# Who will run the code
14uid = {user}
15gid = {user}
17# Number of workers
18workers = 8
20# The right granted on the created socket
21chmod-socket = 666
23# Plugin to use and interpretor config
24single-interpreter = true
25master = true
26plugin = python
28# Module to import
29module = searx.webapp
31# Virtualenv and python path
32virtualenv = {searx_ve_dir}
33pythonpath = {searx_dir}
34chdir = {searx_dir}/searx
35'''.format(user=current_user,
36 searx_dir=searx_dir,
37 searx_ve_dir=searx_ve_dir)
39nginx_config = '''
40server {{
41 listen 80;
42 server_name {hostname};
43 server_name www.{hostname};
44 root /usr/local/searx;
46 location / {{
47 include uwsgi_params;
48 uwsgi_pass unix:/run/uwsgi/app/searx/socket;
49 }}
50}}
51'''.format(hostname=hostname)
54def stop():
55 sudo('/etc/init.d/uwsgi stop')
58def start():
59 sudo('/etc/init.d/uwsgi start')
62def restart():
63 sudo('/etc/init.d/uwsgi restart')
66def init():
67 if not run('test -d ' + searx_dir, warn_only=True).failed:
68 return
70 sudo('apt-get update')
72 sudo('apt-get install git'
73 ' build-essential'
74 ' libxslt-dev'
75 ' python-dev'
76 ' python-virtualenv'
77 ' python-pybabel'
78 ' zlib1g-dev'
79 ' uwsgi'
80 ' uwsgi-plugin-python'
81 ' nginx')
83 sudo('mkdir -p ' + base_dir)
85 put(StringIO(nginx_config), '/etc/nginx/sites-enabled/searx', use_sudo=True)
86 sudo('/etc/init.d/nginx restart')
88 with cd(base_dir):
89 sudo('git clone https://github.com/asciimoo/searx')
91 sudo('chown -R {user}:{user} {searx_dir}'.format(user=current_user, searx_dir=searx_dir))
92 put(StringIO(uwsgi_file), searx_dir+'/uwsgi.ini')
93 sudo('ln -s {0}/uwsgi.ini /etc/uwsgi/apps-enabled/searx.ini'.format(searx_dir))
95 run('virtualenv {0}'.format(searx_ve_dir))
97 with cd(searx_dir):
98 run('source {0}/bin/activate && pip install -r requirements.txt'.format(searx_ve_dir))
100 start()
103def deploy():
104 init()
106 with cd(searx_dir):
107 run("git stash", warn_only=True)
108 run("git pull origin master")
109 run("git stash pop", warn_only=True)
111 restart()
114def clean():
115 sudo('rm -rf {searx_dir}'.format(searx_dir=searx_dir), warn_only=True)
116 sudo('rm /etc/uwsgi/apps-enabled/searx.ini', warn_only=True)
117 sudo('rm /etc/nginx/sites-enabled/searx', warn_only=True)