Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
Nextcloud Notify Push
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
Eduardo Trujillo
Nextcloud Notify Push
Commits
3487dbdc
Commit
3487dbdc
authored
4 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
use unix socket for localhost mysql connections
parent
f5dd80a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/Command/Log.php
+1
-1
1 addition, 1 deletion
lib/Command/Log.php
lib/Command/Setup.php
+2
-2
2 additions, 2 deletions
lib/Command/Setup.php
src/main.rs
+4
-2
4 additions, 2 deletions
src/main.rs
src/storage_mapping.rs
+20
-1
20 additions, 1 deletion
src/storage_mapping.rs
with
27 additions
and
6 deletions
lib/Command/Log.php
+
1
−
1
View file @
3487dbdc
...
...
@@ -34,7 +34,7 @@ class Log extends Base {
private
$queue
;
public
function
__construct
(
IQueue
$queue
,
IQueue
$queue
)
{
parent
::
__construct
();
$this
->
queue
=
$queue
;
...
...
This diff is collapsed.
Click to expand it.
lib/Command/Setup.php
+
2
−
2
View file @
3487dbdc
...
...
@@ -40,7 +40,7 @@ class Setup extends Base {
public
function
__construct
(
\OCA\NotifyPush\SelfTest
$test
,
IConfig
$config
,
SetupWizard
$setupWizard
,
SetupWizard
$setupWizard
)
{
parent
::
__construct
();
$this
->
test
=
$test
;
...
...
@@ -249,7 +249,7 @@ class Setup extends Base {
private
function
enterToContinue
(
OutputInterface
$output
):
bool
{
$output
->
write
(
"Press enter to continue or ESC to cancel..."
);
system
(
'stty cbreak
-echo
'
);
system
(
'stty cbreak'
);
$result
=
null
;
while
(
$result
===
null
)
{
$this
->
abortIfInterrupted
();
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
4
−
2
View file @
3487dbdc
...
...
@@ -38,6 +38,8 @@ async fn main() -> Result<()> {
None
=>
Config
::
from_env
()
.wrap_err
(
"Failed to load config from environment variables"
)
?
,
};
log
::
trace!
(
"Running with config: {:?}"
,
config
);
let
port
=
dotenv
::
var
(
"PORT"
)
.ok
()
.and_then
(|
port
|
port
.parse
()
.ok
())
...
...
@@ -51,14 +53,14 @@ async fn main() -> Result<()> {
DEBOUNCE_ENABLE
.store
(
false
,
Ordering
::
Relaxed
);
}
log
::
trace!
(
"Running with config: {:?} on port {}"
,
config
,
port
);
let
app
=
Arc
::
new
(
App
::
new
(
config
,
log_handle
)
.await
?
);
app
.self_test
()
.await
?
;
log
::
trace!
(
"Listening on port {}"
,
port
);
let
server
=
spawn
(
serve
(
app
.clone
(),
port
,
serve_cancel_handle
));
if
let
Some
(
metrics_port
)
=
metrics_port
{
log
::
trace!
(
"Metrics listening on port {}"
,
port
);
spawn
(
serve_metrics
(
metrics_port
,
metrics_cancel_handle
));
}
...
...
This diff is collapsed.
Click to expand it.
src/storage_mapping.rs
+
20
−
1
View file @
3487dbdc
...
...
@@ -3,9 +3,13 @@ use crate::UserId;
use
color_eyre
::{
eyre
::
WrapErr
,
Result
};
use
dashmap
::
DashMap
;
use
rand
::{
thread_rng
,
Rng
};
use
sqlx
::
any
::
AnyConnectOptions
;
use
sqlx
::
mysql
::
MySqlConnectOptions
;
use
sqlx
::{
Any
,
AnyPool
,
FromRow
};
use
std
::
path
::
PathBuf
;
use
std
::
time
::
Instant
;
use
tokio
::
time
::
Duration
;
use
warp
::
http
::
Uri
;
#[derive(Debug,
Clone,
FromRow)]
pub
struct
UserStorageAccess
{
...
...
@@ -50,8 +54,23 @@ impl StorageMapping {
})
}
fn
parse_options
(
connect
:
&
str
)
->
Result
<
AnyConnectOptions
>
{
let
uri
:
Uri
=
connect
.parse
()
?
;
if
uri
.scheme_str
()
==
Some
(
"mysql"
)
&&
uri
.host
()
==
Some
(
"localhost"
)
{
let
socket_addr
=
PathBuf
::
from
(
"/var/run/mysqld/mysqld.sock"
);
if
socket_addr
.exists
()
{
log
::
trace!
(
"Using unix socket instead of tcp for mysql localhost connection"
);
let
mysql_options
:
MySqlConnectOptions
=
connect
.parse
()
?
;
return
Ok
(
mysql_options
.socket
(
socket_addr
)
.into
());
}
}
Ok
(
connect
.parse
()
?
)
}
pub
async
fn
new
(
connect
:
&
str
,
prefix
:
String
)
->
Result
<
Self
>
{
let
connection
=
AnyPool
::
connect
(
connect
)
let
options
=
Self
::
parse_options
(
connect
)
.wrap_err
(
"Failed to parse SQL connect string"
)
?
;
let
connection
=
AnyPool
::
connect_with
(
options
)
.await
.wrap_err
(
"Failed to connect to Nextcloud database"
)
?
;
...
...
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