[~] Refactor
This commit is contained in:
parent
3c862b2fc5
commit
09d121c865
2
d1/f3.sh
2
d1/f3.sh
@ -1,5 +1,7 @@
|
|||||||
|
$@ 'mkdir -p $HOME/p1/p1; mkdir -p $HOME/tmp'
|
||||||
cat d1/f2.py | $@ sh -c 'cat > $HOME/p1/p1/passenger_wsgi.py'
|
cat d1/f2.py | $@ sh -c 'cat > $HOME/p1/p1/passenger_wsgi.py'
|
||||||
cat tmp/wsgi_config.json | $@ sh -c 'cat > $HOME/p1/p1/wsgi_config.json'
|
cat tmp/wsgi_config.json | $@ sh -c 'cat > $HOME/p1/p1/wsgi_config.json'
|
||||||
cat d1/wsgi/.htaccess | $@ sh -c 'cat > $HOME/public_html/.htaccess'
|
cat d1/wsgi/.htaccess | $@ sh -c 'cat > $HOME/public_html/.htaccess'
|
||||||
|
cat d1/wsgi/busybox | $@ sh -c 'cat > $HOME/tmp/busybox'
|
||||||
cat d1/wsgi/f2.sh | $@ sh -c 'cat > $HOME/p1/p1/f2.sh'
|
cat d1/wsgi/f2.sh | $@ sh -c 'cat > $HOME/p1/p1/f2.sh'
|
||||||
$@ sh p1/p1/f2.sh
|
$@ sh p1/p1/f2.sh
|
||||||
|
@ -13,10 +13,27 @@ with io.open(
|
|||||||
sys.argv[2],
|
sys.argv[2],
|
||||||
'w'
|
'w'
|
||||||
) as f:
|
) as f:
|
||||||
|
names = [o['app_name'] for o in forward_nginx]
|
||||||
|
|
||||||
|
if not '' in names:
|
||||||
|
forward_nginx.append(
|
||||||
|
dict(
|
||||||
|
app_name='',
|
||||||
|
redirect_url='https://product-development-service.blogspot.com',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
sections = []
|
sections = []
|
||||||
for entry in forward_nginx:
|
for entry in forward_nginx:
|
||||||
sections.append(r'''
|
location = None
|
||||||
location ^~ /{app_name}/ {
|
|
||||||
|
if entry['app_name'] != '':
|
||||||
|
location = '/%s/' % entry['app_name']
|
||||||
|
else:
|
||||||
|
location = '/'
|
||||||
|
|
||||||
|
if 'target_endpoint' in entry:
|
||||||
|
section_body = r'''
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host $http_host;
|
||||||
proxy_set_header X-Forwarded-For $t1;
|
proxy_set_header X-Forwarded-For $t1;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
@ -25,11 +42,26 @@ with io.open(
|
|||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_pass {target_endpoint};
|
proxy_pass {target_endpoint};
|
||||||
|
'''.replace(
|
||||||
|
'{target_endpoint}', entry['target_endpoint'],
|
||||||
|
)
|
||||||
|
elif 'redirect_url' in entry:
|
||||||
|
section_body = r'''
|
||||||
|
return 302 {redirect_url}$request_uri;
|
||||||
|
'''.replace(
|
||||||
|
'{redirect_url}', entry['redirect_url'],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
sections.append(r'''
|
||||||
|
location ^~ {location} {
|
||||||
|
{section_body}
|
||||||
}
|
}
|
||||||
'''.replace(
|
'''.replace(
|
||||||
'{app_name}', entry['app_name'],
|
'{section_body}', section_body,
|
||||||
).replace(
|
).replace(
|
||||||
'{target_endpoint}', entry['target_endpoint'],
|
'{location}', location,
|
||||||
))
|
))
|
||||||
f.write(r'''
|
f.write(r'''
|
||||||
events {
|
events {
|
||||||
@ -39,7 +71,7 @@ events {
|
|||||||
|
|
||||||
http {
|
http {
|
||||||
log_format main
|
log_format main
|
||||||
'[$time_local][$remote_addr, $http_x_forwarded_for, $t1]'
|
'[$time_local][$remote_addr, $http_x_forwarded_for, $t1, $http_host]'
|
||||||
'[$request_length,$bytes_sent,$request_time]'
|
'[$request_length,$bytes_sent,$request_time]'
|
||||||
'[$status][$request]'
|
'[$status][$request]'
|
||||||
'[$http_user_agent][$http_referer]';
|
'[$http_user_agent][$http_referer]';
|
||||||
@ -59,10 +91,6 @@ http {
|
|||||||
client_max_body_size 50M;
|
client_max_body_size 50M;
|
||||||
|
|
||||||
{sections_config}
|
{sections_config}
|
||||||
|
|
||||||
location / {
|
|
||||||
return 302 https://product-development-service.blogspot.com$request_uri;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#PassengerLogLevel 7
|
#PassengerLogLevel 7
|
||||||
#PassengerLogFile fuck.txt
|
#PassengerLogFile fuck.txt
|
||||||
#PassengerHighPerformance on
|
#PassengerHighPerformance on
|
||||||
PassengerAppRoot "/home/productg/p1/p1"
|
PassengerAppRoot "/home/{USER}/p1/p1"
|
||||||
PassengerBaseURI "/"
|
PassengerBaseURI "/"
|
||||||
PassengerPython "/home/productg/p1/tmp/env3/bin/python"
|
PassengerPython "/home/{USER}/p1/tmp/env3/bin/python"
|
||||||
PassengerBufferResponse off
|
PassengerBufferResponse off
|
||||||
PassengerBufferUpload off
|
PassengerBufferUpload off
|
||||||
#PassengerMaxRequests 1
|
#PassengerMaxRequests 1
|
||||||
|
BIN
d1/wsgi/busybox
Normal file
BIN
d1/wsgi/busybox
Normal file
Binary file not shown.
@ -1 +1,2 @@
|
|||||||
|
sed -i -e 's/{USER}/'$USER'/' public_html/.htaccess
|
||||||
echo START; pgrep -f -a 'python.*wsgi-loader'; pgrep -f -a 'python.*wsgi-loader' | awk '{print $1}' | xargs kill -s SIGINT; echo AFTER; pgrep -f -a 'python.*wsgi-loader';
|
echo START; pgrep -f -a 'python.*wsgi-loader'; pgrep -f -a 'python.*wsgi-loader' | awk '{print $1}' | xargs kill -s SIGINT; echo AFTER; pgrep -f -a 'python.*wsgi-loader';
|
||||||
|
Loading…
Reference in New Issue
Block a user