Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
d12d5ea5
Valider
d12d5ea5
rédigé
11 years ago
par
mattab
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Refs #4309 when --force-idsites is set, really force the site to be processed
parent
67f594bd
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
core/CronArchive.php
+50
-3
50 ajouts, 3 suppressions
core/CronArchive.php
misc/cron/archive.php
+2
-40
2 ajouts, 40 suppressions
misc/cron/archive.php
avec
52 ajouts
et
43 suppressions
core/CronArchive.php
+
50
−
3
Voir le fichier @
d12d5ea5
...
@@ -21,6 +21,47 @@ use Exception;
...
@@ -21,6 +21,47 @@ use Exception;
*/
*/
class
CronArchive
class
CronArchive
{
{
static
public
function
getUsage
()
{
return
"Usage:
/path/to/cli/php
\"
"
.
@
$_SERVER
[
'argv'
][
0
]
.
"
\"
--url=http://your-website.org/path/to/piwik/ [arguments]
Arguments:
--url=[piwik-server-url]
Mandatory argument. Must be set to the Piwik base URL.
For example: --url=http://analytics.example.org/ or --url=https://example.org/piwik/
--force-all-websites
If specified, the script will trigger archiving on all websites and all past dates.
You may use --force-all-periods=[seconds] to only trigger archiving on those websites that had visits in the last [seconds] seconds.
--force-all-periods[=seconds]
Limits archiving to websites with some traffic in the last [seconds] seconds.
For example --force-all-periods=86400 will archive websites that had visits in the last 24 hours.
If [seconds] is not specified, all websites will visits in the last "
.
CronArchive
::
ARCHIVE_SITES_WITH_TRAFFIC_SINCE
.
" seconds ("
.
round
(
CronArchive
::
ARCHIVE_SITES_WITH_TRAFFIC_SINCE
/
86400
)
.
" days) will be archived.
--force-timeout-for-periods=[seconds]
The current week/ current month/ current year will be processed at most every [seconds].
If not specified, defaults to "
.
CronArchive
::
SECONDS_DELAY_BETWEEN_PERIOD_ARCHIVES
.
".
--force-idsites=1,2,n
Restricts archiving to the specified website IDs, comma separated list.
--xhprof
Enables XHProf profiler for this archive.php run. Requires XHPRof (see tests/README.xhprof.md).
--accept-invalid-ssl-certificate
It is _NOT_ recommended to use this argument. Instead, you should use a valid SSL certificate!
It can be useful if you specified --url=https://... or if you are using Piwik with force_ssl=1
--help
Displays usage
Notes:
* It is recommended to run the script with the argument --url=[piwik-server-url] only. Other arguments are not required.
* This script should be executed every hour via crontab, or as a deamon.
* You can also run it via http:// by specifying the Super User &token_auth=XYZ as a parameter ('Web Cron'),
but it is recommended to run it via command line/CLI instead.
* If you use Piwik to track dozens/hundreds of websites, please let the team know at hello@piwik.org
it makes us happy to learn successful user stories :)
* Enjoy!
"
;
}
// the url can be set here before the init, and it will be used instead of --url=
// the url can be set here before the init, and it will be used instead of --url=
static
public
$url
=
false
;
static
public
$url
=
false
;
...
@@ -166,6 +207,11 @@ class CronArchive
...
@@ -166,6 +207,11 @@ class CronArchive
$shouldArchivePeriods
=
true
;
$shouldArchivePeriods
=
true
;
}
}
$websiteIdIsForced
=
in_array
(
$idsite
,
$this
->
shouldArchiveSpecifiedSites
);
if
(
$websiteIdIsForced
)
{
$shouldArchivePeriods
=
true
;
}
// Test if we should process this website at all
// Test if we should process this website at all
$elapsedSinceLastArchiving
=
time
()
-
$lastTimestampWebsiteProcessedDay
;
$elapsedSinceLastArchiving
=
time
()
-
$lastTimestampWebsiteProcessedDay
;
...
@@ -178,7 +224,9 @@ class CronArchive
...
@@ -178,7 +224,9 @@ class CronArchive
$skipDayArchive
=
$skipDayArchive
&&
!
$websiteIsOldDataInvalidate
;
$skipDayArchive
=
$skipDayArchive
&&
!
$websiteIsOldDataInvalidate
;
// Also reprocess when day has ended since last run
// Also reprocess when day has ended since last run
if
(
$dayHasEndedMustReprocess
&&
!
$existingArchiveIsValid
)
{
if
(
$dayHasEndedMustReprocess
&&
!
$existingArchiveIsValid
&&
!
$websiteIdIsForced
)
{
$skipDayArchive
=
false
;
$skipDayArchive
=
false
;
}
}
...
@@ -611,8 +659,7 @@ class CronArchive
...
@@ -611,8 +659,7 @@ class CronArchive
*/
*/
private
function
usage
()
private
function
usage
()
{
{
global
$USAGE
;
echo
self
::
getUsage
();
echo
$USAGE
;
}
}
/**
/**
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
misc/cron/archive.php
+
2
−
40
Voir le fichier @
d12d5ea5
...
@@ -10,47 +10,9 @@
...
@@ -10,47 +10,9 @@
*/
*/
namespace
Piwik
;
namespace
Piwik
;
use
Exception
;
$USAGE
=
"
Usage:
/path/to/cli/php
\"
"
.
@
$_SERVER
[
'argv'
][
0
]
.
"
\"
--url=http://your-website.org/path/to/piwik/ [arguments]
Arguments:
use
Exception
;
--url=[piwik-server-url]
Mandatory argument. Must be set to the Piwik base URL.
For example: --url=http://analytics.example.org/ or --url=https://example.org/piwik/
--force-all-websites
If specified, the script will trigger archiving on all websites and all past dates.
You may use --force-all-periods=[seconds] to only trigger archiving on those websites that had visits in the last [seconds] seconds.
--force-all-periods[=seconds]
Limits archiving to websites with some traffic in the last [seconds] seconds.
For example --force-all-periods=86400 will archive websites that had visits in the last 24 hours.
If [seconds] is not specified, all websites will visits in the last "
.
CronArchive
::
ARCHIVE_SITES_WITH_TRAFFIC_SINCE
.
" seconds ("
.
round
(
CronArchive
::
ARCHIVE_SITES_WITH_TRAFFIC_SINCE
/
86400
)
.
" days) will be archived.
--force-timeout-for-periods=[seconds]
The current week/ current month/ current year will be processed at most every [seconds].
If not specified, defaults to "
.
CronArchive
::
SECONDS_DELAY_BETWEEN_PERIOD_ARCHIVES
.
".
--force-idsites=1,2,n
Restricts archiving to the specified website IDs, comma separated list.
--xhprof
Enables XHProf profiler for this archive.php run. Requires XHPRof (see tests/README.xhprof.md).
--accept-invalid-ssl-certificate
It is _NOT_ recommended to use this argument. Instead, you should use a valid SSL certificate!
It can be useful if you specified --url=https://... or if you are using Piwik with force_ssl=1
--help
Displays usage
Notes:
* It is recommended to run the script with the argument --url=[piwik-server-url] only. Other arguments are not required.
* This script should be executed every hour via crontab, or as a deamon.
* You can also run it via http:// by specifying the Super User &token_auth=XYZ as a parameter ('Web Cron'),
but it is recommended to run it via command line/CLI instead.
* If you use Piwik to track dozens/hundreds of websites, please let the team know at hello@piwik.org
it makes us happy to learn successful user stories :)
* Enjoy!
"
;
/*
/*
Ideas for improvements:
Ideas for improvements:
- Known limitation: when adding new segments to preprocess, script will assume that data was processed for this segment in the past
- Known limitation: when adding new segments to preprocess, script will assume that data was processed for this segment in the past
...
@@ -77,7 +39,7 @@ if(!defined('PIWIK_MODE_ARCHIVE')) {
...
@@ -77,7 +39,7 @@ if(!defined('PIWIK_MODE_ARCHIVE')) {
require_once
PIWIK_INCLUDE_PATH
.
"/index.php"
;
require_once
PIWIK_INCLUDE_PATH
.
"/index.php"
;
$archiving
=
new
CronArchive
;
$archiving
=
new
CronArchive
()
;
try
{
try
{
$archiving
->
init
();
$archiving
->
init
();
$archiving
->
run
();
$archiving
->
run
();
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter