• I read this topic: https://community.nodebb.org/topic/12275/scripted-maintenance-mode/4

    And there are three ways of turning maintainence mode:

    use myDatabase
    db.objects.update({ _key: "config" }, { $set: { "maintenanceMode": 1 } });

    Then restart nodebb.


    // start-maintenance.js
    db.objects.update({ _key: "config" }, { $set: { "maintenanceMode": 1 } })
    db.objects.update({ _key: "config" }, { $set: { "maintenanceModeMessage": "Backup in progress! We are back online in a few minutes!" } }) 
    mongo -u user -p pass mongo-hostname/nodebb-db-name start-maintenance.js

    1st and 2nd way didn't set maintenance mode on for me.

    3rd is to use api, but i don't know how to use it, could someone point me direction (using bash/python).

    I just realized that maintenance mode returns 503 page, so:

    4th way would be returning 503 page from nginx directly, this is the easiest one. But it requires to write some custom error page.

  • I created read only user in mongodb, replaced user with read only user in config.json. Then added in nginx location block:

    sub_filter </head> '</head><h2 style="text-align:center">Forum in readonly mode.</h2>';

    So now users can browse forum but can't change it (database). And users can read maintenance warning.

    But still i want to know how to set maintenance by api 3rd step, so if soemone have time and knowledge please post it here.

  • Nope just checked, user need to have write permissions to the database otherwise nodebb throws "Internal Error".

  • NodeBB Admin

    Your first option should work setting maintenanceMode to 1 and restarting nodebb should show the maintenance page to regular users.

  • @baris i will try again later, but when i was testing before nothing happened.

  • I also tried db.fsyncLock() / db.fsyncUnlock() on mongo db, to force db to read-only, nodebb show no error but was waiting (loading page).

  • Weird,

    > use nodebb
    switched to db nodebb
    > db.objects.update({ _key: "config" }, { $set: { "maintenanceMode": 1 } });
    WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

    NodeBB restart.

    It's working, checked APC and the switch is turned on.

    I think i was loged in as administrator before, but i was checking maintenance page in APC and switch was turned off.

Suggested Topics

| | | |