Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nginx-redirector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
nginx-redirector
Commits
623eae9a
Commit
623eae9a
authored
Jul 04, 2019
by
Никита Ефремов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a lot of bugs and implemented deletion of unused notifiers
parent
b8b6c22b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
redirector.py
core/redirector.py
+10
-8
No files found.
core/redirector.py
View file @
623eae9a
...
...
@@ -3,10 +3,10 @@ import os
import
pyinotify
import
asyncore
from
mymodul
e
import
generators
from
mymodul
e
import
logger
from
mymodul
e
import
parser
from
mymodul
e
import
const
from
cor
e
import
generators
from
cor
e
import
logger
from
cor
e
import
parser
from
cor
e
import
const
redirector_watch
=
None
...
...
@@ -57,8 +57,8 @@ class RedirectorWatch:
self
.
redirector
=
Redirector
()
self
.
parser
=
parser
.
ConfigReader
(
logger
=
self
.
logger
)
self
.
mask
=
pyinotify
.
IN_MODIFY
self
.
wm_pool
=
[]
self
.
n_pool
=
[]
self
.
pool
=
{}
def
watch
(
self
,
yaml_file
):
if
not
yaml_file
:
...
...
@@ -73,12 +73,15 @@ class RedirectorWatch:
# creating class Watch with custom static 'yaml_file' argument
def
create_watch_class
(
self
,
yaml_file
):
global
redirector_watch
class
Watch
(
pyinotify
.
ProcessEvent
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
redirector
=
kwargs
.
pop
(
"redirector"
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
process_IN_MODIFY
(
self
,
event
):
redirector_watch
.
pool
[
yaml_file
][
1
]
.
stop
()
redirector_watch
.
pool
[
yaml_file
]
=
None
self
.
redirector
.
generate
(
yaml_file
,
event
.
pathname
)
return
Watch
...
...
@@ -86,10 +89,9 @@ class RedirectorWatch:
def
set_inotify
(
self
,
yaml_file
,
Watch_class
):
wm
=
pyinotify
.
WatchManager
()
self
.
add_files
(
yaml_file
,
wm
)
self
.
wm_pool
.
append
(
wm
)
notifier
=
pyinotify
.
ThreadedNotifier
(
wm
,
Watch_class
(
redirector
=
self
.
redirector
))
notifier
.
start
()
self
.
n_pool
.
append
(
notifier
)
self
.
pool
[
yaml_file
]
=
[
wm
,
notifier
]
def
add_files
(
self
,
file_
,
wm
):
file_list
=
self
.
parser
.
parse_yaml
(
file_
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment