Commit 028a28e2 authored by 郑伟's avatar 郑伟

后端服务器

parent 68caf6e0
<table>
<tr>
<th>Category</th>
<th>Directory</th>
</tr>
<tr>
<td>project</td>
<td>/srv/apps/$PROJECT/</td>
</tr>
<tr>
<td>virtualenv</td>
<td>/srv/envs/$PROJECT/</td>
</tr>
<tr>
<td>http-static-files</td>
<td>/srv/static/$PROJECT/</td>
</tr>
<tr>
<td>app-log</td>
<td>/data/log/$PROJECT/app/*.log</td>
</tr>
<tr>
<td>nginx-log</td>
<td>/data/log/$PROJECT/nginx/*.log</td>
</tr>
<tr>
<td>supervisor-log</td>
<td>/data/log/$PROJECT/supervisor/*.log</td>
</tr>
<tr>
<td>nginx</td>
<td>/etc/nginx/gmapps/$PROJECT.conf</td>
</tr>
<tr>
<td>supervisord</td>
<td>/etc/supervisor/gmapps/$PROJECT.conf</td>
</tr>
<tr>
<td>logrotate</td>
<td>/etc/logrotate.d/gmapps/$PROJECT.conf</td>
</tr>
</table>
PROJECT={prj_name} && mkdir -p /srv/apps/$PROJECT/ /srv/envs/$PROJECT/ /srv/static/$PROJECT/ /data/log/$PROJECT/app/ /data/log/$PROJECT/nginx/ /data/log/$PROJECT/supervisor/
# conf example
## nginx
server {
listen 80;
server_name {{domain}};
root /srv/apps/{{PROJECT}};
location / {
proxy_pass {{GUNICORN BIND}};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
alias /srv/static/{{PROJECT}}/;
expires 864000;
}
access_log /data/log/{{PROJECT}}/nginx/access.log combined;
}
## supervisord
[program:{{PROJECT}}]
command = /srv/envs/{{PROJECT}}/bin/gunicorn {{PROJECT}}.wsgi:application -w=5 -b {{HOST:PORT}}
directory = /srv/apps/{{PROJECT}}
redirect_stderr = true
stdout_logfile = /data/log/{{PROJECT}}/supervisor/supervisor.log
# misc for convenience
## automatically activate virtual env
####### file .gengmei.bash #######
# put into .bashrc.
# if [ -f ~/.gengmei.bash ];then
# source ~/.gengmei.bash
# fi
# usage: cd {project_dir}
APPPATH=/srv/apps
ENVPATH=/srv/envs
function cd(){
builtin cd $1;
fullpath=`pwd`;
dirpath=`dirname $fullpath`;
appname=`basename $fullpath`;
if [ $dirpath = $APPPATH ];then
source $ENVPATH/$appname/bin/activate;
fi
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment