GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Code listing (detail) of index.page.js in Helix Editor: const RestoreStatusUpdate = ({SLOT}) => kitten.html` <div id='restore-status' class='progress'> <${ProgressIndicator} /> ${SLOT} </div> ` export function onConnect ({request, page}) { page.on('startRestore', () => { page.send(kitten.html`<${RestoreStatusUpdate}>Uploading backup to restore from…</>`) }) const restoreDatabases = async (/** @type {Upload} */ upload) => { console.log('Restore: database backup uploaded', upload) // Show status indicator. page.send(kitten.html`<${RestoreStatusUpdate}>Restoring from backup…</>`) // Delete current databases. const deleteResult = await fs.rm(kitten.databaseDirectory, {recursive: true, force: true}) // Re-create databases directory. const makeDirectoryResult = await fs.mkdir(kitten.databaseDirectory) // Decompress backed-up databases. await extract({ cwd: kitten.databaseDirectory, file: upload.filePath }) // Send refresh header and restart the server so the // restored databases are loaded into memory. page.send(kitten.html`<${RestoreStatusUpdate}>Restore complete, waiting for server restart…`) // Restart the server. process.exit(99 /* code for restart request */) } request.session.removeListener('databasesUploadedForRestore', restoreDatabases) request.session.addListener('databasesUploadedForRestore', restoreDatabases)

Download link

https://s3-eu-central-1.amazonaws.com/mastodon-aral/media_attachments/files/112/383/600/481/486/638/original/a61cee66dc0a4ca4.png

Notices where this attachment appears

  1. Embed this notice
    Aral Balkan (aral@mastodon.ar.al)'s status on Sunday, 05-May-2024 00:51:03 JST Aral Balkan Aral Balkan
    in reply to

    🎉 Got database backup and restore working in Kitten (so every Kitten app gets it for free) and, with the new JSDB 5 support in Kitten, you can now make your model classes EventEmitters.

    The session object is now an EventEmitter so you can now listen for events on the current session. In fact, I did just that in Kitten itself to implement the upload of the backup file during the restore process to make the Streaming HTML handler get notified once the POST route has the upload.

    #SmallWeb #Kitten

    In conversation about a year ago from mastodon.ar.al permalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.