Skip to content

Commit

Permalink
Pull strategy + sample configs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderM91 committed Oct 15, 2020
1 parent cf2228d commit 095ec01
Show file tree
Hide file tree
Showing 2 changed files with 379 additions and 2 deletions.
67 changes: 65 additions & 2 deletions bin/storage-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,56 @@ var storage = new StandaloneStorage(config.Storage, function(err) {
case 'install':
// setup new master server
var setup = require('../conf/setup.json');

var events = require('../conf/samples.json');

// spawn worker process

// const events = cp.spawn(
// 'vendor/bin/console', ['scheduler:export']
// );
//
// events.stdout.on('data', (data) => {
// console.log(`stdout: ${data}`);

var categories = {};
for (var key in events) {
let cat = {
'max_children': 0,
'enabled': 1
};
let event = JSON.parse(JSON.stringify(events[key]));
let categoryTitle = event.title.split('__')[0].toString().replace(/\W+/g, '');

if (categories.hasOwnProperty(categoryTitle)) {
cat.id = event.category = categories[categoryTitle];
cat.title = categoryTitle;
}

if (event.category === null) {
let categoryId = generateUniqueID(categoryTitle);
cat.title = categoryTitle;
cat.id = categories[categoryTitle] = event.category = categoryId;
}

storage.listFind( 'global/categories', { id: cat.id }, function(err, categoryById) {
if (categoryById) {
print('category', "The category with the given ID already exists: " + cat.id);
}

storage.listUnshift( 'global/categories', cat, function(err) {
if (err) {
print('category', "Failed to create category: " + err);
}
});
});

storage.listUnshift('global/schedule', event, function(err) {
if (err) {
print('schedule', "Failed to create scheduler: " + err);
}
});
}

// make sure this is only run once
storage.get( 'global/users', function(err) {
if (!err) {
Expand Down Expand Up @@ -216,7 +265,8 @@ var storage = new StandaloneStorage(config.Storage, function(err) {
print("\n");

storage.shutdown( function() { process.exit(0); } );
} );
});

break;

case 'get':
Expand Down Expand Up @@ -608,3 +658,16 @@ function import_data(file) {
else queue.drain = complete;
}); // rl close
};

var _uniqueIDCounter = 0;
function generateUniqueID(prefix) {
this._uniqueIDCounter++;

if (this._uniqueIDCounter >= Math.pow(36, 2)) this._uniqueIDCounter = 0;

return [
prefix,
Tools.zeroPad( (new Date()).getTime().toString(36), 8 ),
Tools.zeroPad( this._uniqueIDCounter.toString(36), 2 )
].join('');
}
314 changes: 314 additions & 0 deletions sample_conf/samples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
[
{
"title": "DE__check-product-validity",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console product:check-validity\\n"
},
"timing": {
"minutes": [
0
],
"hours": [
6
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__check-product-label-validity",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console product-label:validity\\n"
},
"timing": {
"minutes": [
0
],
"hours": [
6
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__update-product-label-relations",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console product-label:relations:update -vvv --no-touch\\n"
},
"timing": {
"minutes": [],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__check-oms-conditions",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console oms:check-condition\\n"
},
"timing": {
"minutes": [],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__check-oms-timeouts",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console oms:check-timeout\\n"
},
"timing": {
"minutes": [],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__clear-oms-locks",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console oms:clear-locks\\n"
},
"timing": {
"minutes": [
0
],
"hours": [
6
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__queue-worker-start",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console queue:worker:start\\n"
},
"timing": {
"minutes": [],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__product-relation-updater",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console product-relation:update -vvv\\n"
},
"timing": {
"minutes": [
30
],
"hours": [
2
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__event-trigger-timeout",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console event:trigger:timeout -vvv\\n"
},
"timing": {
"minutes": [
0
],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__deactivate-discontinued-products",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console deactivate-discontinued-products\\n"
},
"timing": {
"minutes": [
0
],
"hours": [
0
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__clean-expired-guest-cart",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console quote:delete-expired-guest-quotes\\n"
},
"timing": {
"minutes": [
30
],
"hours": [
1
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__close-outdated-quote-requests",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console quote-request:close-outdated\\n"
},
"timing": {
"minutes": [
0
],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__apply-price-product-schedule",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console price-product-schedule:apply\\n"
},
"timing": {
"minutes": [
0
],
"hours": [
6
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__check-product-offer-validity",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console product-offer:check-validity\\n"
},
"timing": {
"minutes": [
0
],
"hours": [
6
],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__remove-expired-refresh-tokens",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console oauth:refresh-token:remove-expired\\n"
},
"timing": {
"minutes": [
0
],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
},
{
"title": "DE__order-invoice-send",
"enabled": true,
"plugin": "shellplug",
"category": null,
"target": "scheduler.spryker.local",
"params": {
"script": "#!\/bin\/bash\\n $PHP_BIN vendor\/bin\/console order:invoice:send\\n"
},
"timing": {
"minutes": [
0
],
"hours": [],
"days": [],
"months": [],
"weekdays": []
}
}
]

0 comments on commit 095ec01

Please sign in to comment.