As I've added a async hook, which sends login requests to Discourse in order to trigger its sync logic, onto the Dashboard User model. So all we need to do is to perform a save action, and it's exactly what this simple script do.
Let's walk through the procedure step by step.
###Prerequisites
openmrs-contrib-id-sso
module with ID-105 feature.- Shutdown dashboard
- Disable
db-admin
module temporarily.
Edit conf.js
to achieve this.
###Inject this script
Relative to Dashboard's root directory, put this script under app/scripts/talk.js
.
And append this line at the bottom of app/app.js
require('./scripts/talk');
To ease server's pressure, the script will send out requests by batch. In the top of the script, you can see two paramter, payload
and period
, which means we'll send at most payload
requests every period
milliseconds. You need to set this by your own judgement.
###Start the magic
Just start the dashboard by node app/app.js
and the script will be performed
However, as the sync process is fully async, and we can't know when it will end.
The ending message finished sending requests, wait..........
only suggests that we've sent out all the requests.
So after that you need to determine the ending time by yourself, usually just wait some 10s of seconds will be fine with respect to your setting.
###Then
The logs are also stored in app/scripts/talk.log
.
Once it's done, check the log file and search error
log.
Item that looks like this, [ERROR] discourse-sso - Failed to sync user 'username'
, records those users that have failed to sync.
You have to deal with this manually, it's also simple, just login to formage and find that user and save it. Then the sync hook will be triggered once again.
###Clean up Remove the file we created and get the source clean.
rm app/scripts -rf
git checkout -- app/app.js
Don't forget to restore your conf.js.