Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miniflux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
miniflux
Commits
c85b1909
Commit
c85b1909
authored
1 year ago
by
Frédéric Guillot
Browse files
Options
Downloads
Patches
Plain Diff
Add the possibility to run Miniflux as a cronjob
parent
c3250257
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cli/cli.go
+20
-0
20 additions, 0 deletions
cli/cli.go
miniflux.1
+7
-1
7 additions, 1 deletion
miniflux.1
service/scheduler/scheduler.go
+1
-1
1 addition, 1 deletion
service/scheduler/scheduler.go
with
28 additions
and
2 deletions
cli/cli.go
+
20
−
0
View file @
c85b1909
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"miniflux.app/database"
"miniflux.app/database"
"miniflux.app/locale"
"miniflux.app/locale"
"miniflux.app/logger"
"miniflux.app/logger"
feedHandler
"miniflux.app/reader/handler"
"miniflux.app/storage"
"miniflux.app/storage"
"miniflux.app/ui/static"
"miniflux.app/ui/static"
"miniflux.app/version"
"miniflux.app/version"
...
@@ -28,6 +29,7 @@ const (
...
@@ -28,6 +29,7 @@ const (
flagConfigFileHelp
=
"Load configuration file"
flagConfigFileHelp
=
"Load configuration file"
flagConfigDumpHelp
=
"Print parsed configuration values"
flagConfigDumpHelp
=
"Print parsed configuration values"
flagHealthCheckHelp
=
`Perform a health check on the given endpoint (the value "auto" try to guess the health check endpoint).`
flagHealthCheckHelp
=
`Perform a health check on the given endpoint (the value "auto" try to guess the health check endpoint).`
flagCronjobHelp
=
"Run Miniflux as a cronjob to refresh a batch of feeds and exit"
)
)
// Parse parses command line arguments.
// Parse parses command line arguments.
...
@@ -45,6 +47,7 @@ func Parse() {
...
@@ -45,6 +47,7 @@ func Parse() {
flagConfigFile
string
flagConfigFile
string
flagConfigDump
bool
flagConfigDump
bool
flagHealthCheck
string
flagHealthCheck
string
flagCronjob
bool
)
)
flag
.
BoolVar
(
&
flagInfo
,
"info"
,
false
,
flagInfoHelp
)
flag
.
BoolVar
(
&
flagInfo
,
"info"
,
false
,
flagInfoHelp
)
...
@@ -61,6 +64,7 @@ func Parse() {
...
@@ -61,6 +64,7 @@ func Parse() {
flag
.
StringVar
(
&
flagConfigFile
,
"c"
,
""
,
flagConfigFileHelp
)
flag
.
StringVar
(
&
flagConfigFile
,
"c"
,
""
,
flagConfigFileHelp
)
flag
.
BoolVar
(
&
flagConfigDump
,
"config-dump"
,
false
,
flagConfigDumpHelp
)
flag
.
BoolVar
(
&
flagConfigDump
,
"config-dump"
,
false
,
flagConfigDumpHelp
)
flag
.
StringVar
(
&
flagHealthCheck
,
"healthcheck"
,
""
,
flagHealthCheckHelp
)
flag
.
StringVar
(
&
flagHealthCheck
,
"healthcheck"
,
""
,
flagHealthCheckHelp
)
flag
.
BoolVar
(
&
flagCronjob
,
"cronjob"
,
false
,
flagCronjobHelp
)
flag
.
Parse
()
flag
.
Parse
()
cfg
:=
config
.
NewParser
()
cfg
:=
config
.
NewParser
()
...
@@ -187,5 +191,21 @@ func Parse() {
...
@@ -187,5 +191,21 @@ func Parse() {
createAdmin
(
store
)
createAdmin
(
store
)
}
}
if
flagCronjob
{
jobs
,
err
:=
store
.
NewBatch
(
config
.
Opts
.
BatchSize
())
if
err
!=
nil
{
logger
.
Error
(
"[Cronjob] %v"
,
err
)
}
logger
.
Info
(
"[Cronjob]] Processing %d jobs"
,
len
(
jobs
))
for
_
,
job
:=
range
jobs
{
if
err
:=
feedHandler
.
RefreshFeed
(
store
,
job
.
UserID
,
job
.
FeedID
);
err
!=
nil
{
logger
.
Error
(
"[Cronjob] Refreshing the feed #%d returned this error: %v"
,
job
.
FeedID
,
err
)
}
}
return
}
startDaemon
(
store
)
startDaemon
(
store
)
}
}
This diff is collapsed.
Click to expand it.
miniflux.1
+
7
−
1
View file @
c85b1909
...
@@ -6,13 +6,19 @@ miniflux \- Minimalist and opinionated feed reader
...
@@ -6,13 +6,19 @@ miniflux \- Minimalist and opinionated feed reader
.SH SYNOPSIS
.SH SYNOPSIS
\fBminiflux\fR [-vic] [-create-admin] [-debug] [-flush-sessions] [-info] [-migrate]
\fBminiflux\fR [-vic] [-create-admin] [-debug] [-flush-sessions] [-info] [-migrate]
[-reset-feed-errors] [-reset-password] [-version] [-config-file] [-config-dump]
[-reset-feed-errors] [-reset-password] [-version] [-config-file]
[-config-dump] [-cronjob] [-healthcheck]
.SH DESCRIPTION
.SH DESCRIPTION
\fBminiflux\fR is a minimalist and opinionated feed reader.
\fBminiflux\fR is a minimalist and opinionated feed reader.
.SH OPTIONS
.SH OPTIONS
.PP
.PP
.B \-cronjob
.RS 4
Run Miniflux as a cronjob to refresh a batch of feeds and exit\&.
.RE
.PP
.B \-c
.B \-c
.RS 4
.RS 4
Load configuration file\&.
Load configuration file\&.
...
...
This diff is collapsed.
Click to expand it.
service/scheduler/scheduler.go
+
1
−
1
View file @
c85b1909
...
@@ -38,10 +38,10 @@ func Serve(store *storage.Storage, pool *worker.Pool) {
...
@@ -38,10 +38,10 @@ func Serve(store *storage.Storage, pool *worker.Pool) {
func
feedScheduler
(
store
*
storage
.
Storage
,
pool
*
worker
.
Pool
,
frequency
,
batchSize
int
)
{
func
feedScheduler
(
store
*
storage
.
Storage
,
pool
*
worker
.
Pool
,
frequency
,
batchSize
int
)
{
for
range
time
.
Tick
(
time
.
Duration
(
frequency
)
*
time
.
Minute
)
{
for
range
time
.
Tick
(
time
.
Duration
(
frequency
)
*
time
.
Minute
)
{
jobs
,
err
:=
store
.
NewBatch
(
batchSize
)
jobs
,
err
:=
store
.
NewBatch
(
batchSize
)
logger
.
Info
(
"[Scheduler:Feed] Pushing %d jobs to the queue"
,
len
(
jobs
))
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"[Scheduler:Feed] %v"
,
err
)
logger
.
Error
(
"[Scheduler:Feed] %v"
,
err
)
}
else
{
}
else
{
logger
.
Debug
(
"[Scheduler:Feed] Pushing %d jobs"
,
len
(
jobs
))
pool
.
Push
(
jobs
)
pool
.
Push
(
jobs
)
}
}
}
}
...
...
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