Skip to content

Commit

Permalink
set config.primary with argv (#395)
Browse files Browse the repository at this point in the history
* set config.primary with argv

* Update bin/run.js

it works :)

Co-authored-by: Ruslan Kabalin <ruslan.kabalin@gmail.com>

* Update docker-compose.yml

set --primary as default cmd for dev env

Co-authored-by: Ruslan Kabalin <ruslan.kabalin@gmail.com>
  • Loading branch information
aeifn and kabalin authored Oct 14, 2021
1 parent 8a07e43 commit 4792885
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ if (require.main !== module) { // If run.js is required by another module (for e
describe: 'Log config',
'default': true,
})
.options('primary', {
describe: 'Run as primary instance',
})
.argv;

const config = require('../config');
Expand All @@ -53,6 +56,7 @@ if (require.main !== module) { // If run.js is required by another module (for e
const appName = path.parse(argv.script).name;
const logger = log4js.getLogger(appName);
if (appName === "notifier") config.notifier = true;
config.primary = !!argv.primary; // If not true, the instance will run as a recplica

// Handling uncaught exceptions
process.on('uncaughtException', err => {
Expand Down
1 change: 0 additions & 1 deletion config/default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
env: 'development', // Enviroment: development, testing, production
locales: ['en', 'ru'], // List of supported locales. First one is the default locale, if user transferred nothing
lang: 'ru', // Language: ru, en
primary: false, // If not true, the instance will run as a recplica
admin: {
email: '',
},
Expand Down
1 change: 0 additions & 1 deletion config/local.config.js.docker-example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = function (config, appRequire) {

_.merge(config, {
// Send periodical emails to users depending on environment variable
primary: true,
client: {
hostname: 'localhost',
},
Expand Down
1 change: 0 additions & 1 deletion config/local.config.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = function (config, appRequire) {
const _ = appRequire('lodash');

_.merge(config, {
primary: true,
client: {
hostname: 'pastvu.local',
},
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
volumes:
- .:/code
- store:/store
command: run app
command: run app --primary

notifier:
<< : *app-image
Expand Down

0 comments on commit 4792885

Please sign in to comment.