Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
82be4457
Commit
82be4457
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add twisted Service interface
parent
a039e254
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/app/homeserver.py
+18
-3
18 additions, 3 deletions
synapse/app/homeserver.py
synapse/storage/_base.py
+1
-0
1 addition, 0 deletions
synapse/storage/_base.py
with
19 additions
and
3 deletions
synapse/app/homeserver.py
+
18
−
3
View file @
82be4457
...
@@ -19,6 +19,7 @@ from synapse.storage import prepare_database, UpgradeDatabaseException
...
@@ -19,6 +19,7 @@ from synapse.storage import prepare_database, UpgradeDatabaseException
from
synapse.server
import
HomeServer
from
synapse.server
import
HomeServer
from
twisted.internet
import
reactor
from
twisted.internet
import
reactor
from
twisted.application
import
service
from
twisted.enterprise
import
adbapi
from
twisted.enterprise
import
adbapi
from
twisted.web.resource
import
Resource
from
twisted.web.resource
import
Resource
from
twisted.web.static
import
File
from
twisted.web.static
import
File
...
@@ -189,10 +190,10 @@ class SynapseHomeServer(HomeServer):
...
@@ -189,10 +190,10 @@ class SynapseHomeServer(HomeServer):
logger
.
info
(
"
Synapse now listening on port %d
"
,
unsecure_port
)
logger
.
info
(
"
Synapse now listening on port %d
"
,
unsecure_port
)
def
setup
():
def
setup
(
config_options
,
should_run
=
True
):
config
=
HomeServerConfig
.
load_config
(
config
=
HomeServerConfig
.
load_config
(
"
Synapse Homeserver
"
,
"
Synapse Homeserver
"
,
sys
.
argv
[
1
:]
,
config_options
,
generate_section
=
"
Homeserver
"
generate_section
=
"
Homeserver
"
)
)
...
@@ -254,6 +255,9 @@ def setup():
...
@@ -254,6 +255,9 @@ def setup():
bind_port
=
None
bind_port
=
None
hs
.
start_listening
(
bind_port
,
config
.
unsecure_port
)
hs
.
start_listening
(
bind_port
,
config
.
unsecure_port
)
if
not
should_run
:
return
if
config
.
daemonize
:
if
config
.
daemonize
:
print
config
.
pid_file
print
config
.
pid_file
daemon
=
Daemonize
(
daemon
=
Daemonize
(
...
@@ -270,6 +274,17 @@ def setup():
...
@@ -270,6 +274,17 @@ def setup():
reactor
.
run
()
reactor
.
run
()
class
SynapseService
(
service
.
Service
):
def
__init__
(
self
,
config
):
self
.
config
=
config
def
startService
(
self
):
setup
(
self
.
config
,
should_run
=
False
)
def
stopService
(
self
):
return
self
.
_port
.
stopListening
()
def
run
():
def
run
():
with
LoggingContext
(
"
run
"
):
with
LoggingContext
(
"
run
"
):
reactor
.
run
()
reactor
.
run
()
...
@@ -277,7 +292,7 @@ def run():
...
@@ -277,7 +292,7 @@ def run():
def
main
():
def
main
():
with
LoggingContext
(
"
main
"
):
with
LoggingContext
(
"
main
"
):
setup
()
setup
(
sys
.
argv
[
1
:]
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/_base.py
+
1
−
0
View file @
82be4457
...
@@ -95,6 +95,7 @@ class SQLBaseStore(object):
...
@@ -95,6 +95,7 @@ class SQLBaseStore(object):
current_context
.
copy_to
(
context
)
current_context
.
copy_to
(
context
)
start
=
time
.
time
()
*
1000
start
=
time
.
time
()
*
1000
txn_id
=
SQLBaseStore
.
_TXN_ID
txn_id
=
SQLBaseStore
.
_TXN_ID
SQLBaseStore
.
_TXN_ID
+=
1
# We don't really need these to be unique, so lets stop it from
# We don't really need these to be unique, so lets stop it from
# growing really large.
# growing really large.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment