2019-06-21 23:52:18 +02:00
|
|
|
#!/usr/bin/env node
|
2019-07-03 16:58:24 +02:00
|
|
|
process.env.NODE_ENV = 'production'
|
2019-06-25 01:05:38 +02:00
|
|
|
|
2019-11-06 11:31:56 +01:00
|
|
|
const pkg = require('../package.json')
|
2019-07-03 16:58:24 +02:00
|
|
|
const path = require('path')
|
2019-06-21 23:52:18 +02:00
|
|
|
|
2019-07-03 16:58:24 +02:00
|
|
|
const cwd = process.cwd()
|
2021-06-04 15:36:03 +02:00
|
|
|
const data_path = process.env.GANCIO_DATA || path.resolve('./')
|
2019-07-03 16:58:24 +02:00
|
|
|
|
|
|
|
// needed by nuxt
|
2021-09-27 10:42:17 +02:00
|
|
|
// process.chdir(path.resolve(__dirname, '..'))
|
|
|
|
|
|
|
|
// async function run_migrations (db_conf) {
|
|
|
|
// const Umzug = require('umzug')
|
|
|
|
// const Sequelize = require('sequelize')
|
|
|
|
// try {
|
|
|
|
// const db = new Sequelize(db_conf)
|
|
|
|
// const umzug = new Umzug({
|
|
|
|
// storage: 'sequelize',
|
|
|
|
// storageOptions: { sequelize: db },
|
|
|
|
// logging: consola.info,
|
|
|
|
// migrations: {
|
|
|
|
// wrap: fun => {
|
|
|
|
// return () =>
|
|
|
|
// fun(db.queryInterface, Sequelize).catch(e => {
|
|
|
|
// consola.error(e)
|
|
|
|
// return false
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
// path: path.resolve(__dirname, 'migrations')
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// await umzug.up()
|
|
|
|
// return db.close()
|
|
|
|
// } catch (e) {
|
|
|
|
// consola.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`)
|
|
|
|
// process.exit(-1)
|
|
|
|
// }
|
|
|
|
// }
|
2019-06-21 23:52:18 +02:00
|
|
|
|
2021-09-27 10:42:17 +02:00
|
|
|
async function start (options) {
|
2021-06-04 15:36:03 +02:00
|
|
|
try {
|
2021-09-27 10:42:17 +02:00
|
|
|
const config = require('./config')
|
|
|
|
config.load()
|
|
|
|
console.info(`Logging to ${path.resolve(`${config.log_path}/gancio.log`)} [level: ${config.log_level}]`)
|
2021-06-04 15:36:03 +02:00
|
|
|
} catch (e) {
|
2021-09-27 10:42:17 +02:00
|
|
|
console.error(e)
|
2021-06-04 15:36:03 +02:00
|
|
|
process.exit(-1)
|
|
|
|
}
|
2021-04-28 12:44:26 +02:00
|
|
|
|
2019-07-03 16:58:24 +02:00
|
|
|
require('./index')
|
|
|
|
}
|
|
|
|
|
2021-09-27 10:42:17 +02:00
|
|
|
// async function setup (options)
|
|
|
|
console.info(`📅 ${pkg.name} - v${pkg.version} - ${pkg.description} (nodejs: ${process.version})`)
|
2019-07-03 16:58:24 +02:00
|
|
|
|
|
|
|
require('yargs')
|
2019-11-06 11:31:56 +01:00
|
|
|
.usage('Usage $0 <command> [options]')
|
|
|
|
.option('docker', {
|
|
|
|
alias: 'd',
|
|
|
|
describe: 'Inside docker',
|
|
|
|
default: false,
|
|
|
|
type: 'boolean'
|
|
|
|
})
|
|
|
|
.option('db', {
|
|
|
|
describe: 'Specify db type'
|
|
|
|
})
|
|
|
|
.option('config', {
|
|
|
|
alias: 'c',
|
|
|
|
describe: 'Configuration file',
|
2021-06-04 15:36:03 +02:00
|
|
|
default: path.resolve(data_path, 'config.json')
|
2019-11-06 11:31:56 +01:00
|
|
|
})
|
|
|
|
.coerce('config', config_path => {
|
|
|
|
const absolute_config_path = path.resolve(cwd, config_path)
|
|
|
|
process.env.config_path = absolute_config_path
|
|
|
|
return absolute_config_path
|
|
|
|
})
|
|
|
|
.command(['start', 'run', '$0'], 'Start gancio', {}, start)
|
|
|
|
.help('h')
|
|
|
|
.alias('h', 'help')
|
|
|
|
.epilog('Made with ❤ by underscore hacklab - https://gancio.org')
|
2019-11-06 14:47:44 +01:00
|
|
|
.argv
|