forked from gitbeyond/ansible_roles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
311 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
allow_duplicates: true | ||
|
||
dependencies: | ||
- role: common_create_user | ||
#name: create_prom_user | ||
tags: | ||
- common_create_user | ||
- role: common_create_dir | ||
tags: | ||
- common_create_dir | ||
- role: common_packet_install | ||
tags: | ||
- common_packet_install | ||
- role: common_copy_conf_file | ||
tags: | ||
- common_copy_conf_file | ||
- role: common_boot_app | ||
tags: | ||
- common_boot_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[program:{{common_svc_name}}] | ||
command={%if project_prog_run_args is string%}{{project_prog_run_args}}{%else%}{{ project_prog_run_args | join(' ')}}{%endif%} | ||
|
||
directory={{project_install_dir}} | ||
#process_name=%(program_name)s_%(process_num)s | ||
stdout_logfile={{project_log_dir}}/%(program_name)s_std.log | ||
stdout_logfile_backups= 5 | ||
stdout_events_enabled = false | ||
stdout_capture_maxbytes=1MB | ||
stdout_logfile_maxbytes=200MB | ||
stderr_logfile={{project_log_dir}}/%(program_name)s_err.log | ||
stderr_logfile_maxbytes=200MB | ||
stderr_logfile_backups= 5 | ||
stderr_capture_maxbytes=1MB | ||
stderr_events_enabled = false | ||
{%if project_prog_envs |length >0-%} | ||
environment= | ||
{%-for env in project_prog_envs-%} | ||
{{env}}={{project_prog_envs[env]}} | ||
{%-if env != project_prog_envs[-1]-%} | ||
, | ||
{%-endif-%} | ||
{%-endfor-%} | ||
{%-endif%} | ||
numprocs=1 | ||
user = {{project_run_user}} | ||
stopsignal=TERM | ||
autostart=true | ||
autorestart=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 复制配置文件,默认情况下会触发自动重启 | ||
- name: copy project conf files | ||
template: | ||
src: "{{item}}" | ||
dest: "{{project_conf_dir}}" | ||
owner: "{{project_run_user}}" | ||
group: "{{project_run_group}}" | ||
mode: "0644" | ||
backup: yes | ||
register: copy_proxy_nginx_file | ||
loop: '{{project_conf_files}}' | ||
when: | ||
- item is not none | ||
- item != '' | ||
tags: | ||
- project_copy_confs | ||
notify: supervisorctl_restart_prog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
def binary_cur(arr, item): | ||
if not arr: | ||
return False | ||
|
||
mid = len(arr) / 2 | ||
if item == arr[mid]: | ||
return item | ||
# 如果 item > arr[mid],那么要往右侧找 | ||
# 以 item 为 7 来举例 | ||
# 7 > arr[5] | ||
# arr[5:] = [ 6, 7, 8, 9, 10] | ||
|
||
elif item > arr[mid]: | ||
print("item > %d, %d" %(arr[mid], mid)) | ||
#return binary_cur(arr[mid+1:], item) | ||
#return binary_cur(arr[mid+1:], item) | ||
return binary_cur(arr[mid:], item) | ||
else: | ||
# 7 < arr[2] = 8 | ||
# arr[:2] = [6, 7] | ||
print("item < %d, %d" %(arr[mid], mid)) | ||
return binary_cur(arr[:mid], item) | ||
|
||
def binary_search(arr, item): | ||
if not arr: | ||
return False | ||
|
||
#idx = 0 | ||
start = 0 | ||
end = len(arr)-1 | ||
|
||
# 开始和结束位置没有问题就一直循环 | ||
while start <= end: | ||
|
||
mid = (start + end) / 2 | ||
|
||
if item == arr[mid]: | ||
return item | ||
|
||
# 如果数组元素比 item 大,那么说明要往左侧找 | ||
# 以 7 举例子 | ||
# mid = 4 | ||
# arr[4] < 5 | ||
# start = mid +1 = 5 | ||
# second loop | ||
# mid = (5 + 9) / 2 = 7 | ||
# arr[7]=8 > 7 | ||
# end = 7 - 1 = 6 | ||
# third loop | ||
# arr[6] == 7 | ||
|
||
elif arr[mid] > item: | ||
#arr_len = arr_len / 2 - arr_len | ||
print("item > %d, mid: %d" %(arr[mid], mid)) | ||
# 假设这里把 arr_len 长度自减了一半 | ||
end = mid - 1 | ||
else: | ||
print("item < %d, mid: %d " %(arr[mid], mid)) | ||
start = mid + 1 | ||
|
||
return False | ||
|
||
|
||
|
||
|
||
a = [1,2,3,4,5,6,7,8,9,10,11] | ||
b = [ 35, 46, 57, 68, 79, 90, 101, 112, 120, 130, 146, 147, 150] | ||
|
||
#print(binary_search(a, 8)) | ||
for i in a: | ||
#print(binary_search(b, i)) | ||
#print(binary_cur(b, i)) | ||
print(binary_cur(a, i)) | ||
|
Oops, something went wrong.