import { Meteor } from 'meteor/meteor'; import { hasRole } from '../../../authorization'; Meteor.methods({ restart_server() { if (!Meteor.userId()) { throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'restart_server' }); } if (hasRole(Meteor.userId(), 'admin') !== true) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'restart_server' }); } Meteor.setTimeout(() => { Meteor.setTimeout(() => { console.warn('Call to process.exit() timed out, aborting.'); process.abort(); }, 1000); process.exit(1); }, 1000); return { message: 'The_server_will_restart_in_s_seconds', params: [2], }; }, });