Skip to content

Configure

Having issues with configuration ?

241 Topics 4.3k Posts

Subcategories


  • Looking to revamp your site layout?

    121 Topics
    2k Posts

    @crazycells it is, yes - I think I’ll leave it as there is no specific PWA CSS classes I know of. Well, you could use something like the below, but this means multiple CSS files for different operating systems.

    /** * Determine the mobile operating system. * This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'. * * @returns {String} */ function getMobileOperatingSystem() { var userAgent = navigator.userAgent || navigator.vendor || window.opera; // Windows Phone must come first because its UA also contains "Android" if (/windows phone/i.test(userAgent)) { return "Windows Phone"; } if (/android/i.test(userAgent)) { return "Android"; } if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { return "iOS"; } return "unknown"; // return “Android” - one should either handle the unknown or fallback to a specific platform, let’s say Android }

    Once you’re in that rabbit hole, it’s impossible to get out of it.

  • Problems with performance ?

    19 Topics
    284 Posts

    Lower grade VPS instances, whilst cheap, do have the inherent issue in the fact that they only have 1Gb of RAM. In most cases, this is enough for relatively small or minor projects, but when you need more RAM that you actually have, you’ll quickly find that instance exhausted, and your applications crashing as a result.

    This is where the swap file comes into play. Adding a swap can significantly improve performance on low budget hosts, but without direct root access, this is not going to be possible. If you own a VPS that has root level access and need to add a swap, follow the below guide.

    First, what exactly is a Swap?

    swap is a section of hard disk space that has been set reserved for the operating system to temporarily store data that it is unable to hold in RAM. This step allows you increase the amount of information that your server can keep in its working memory (but not without with some caveats, which I’ll explain below). The swap space on the hard disk will be used mostly when there is no more sufficient space in RAM to host any in-use application data.

    The information written to disk will be far slower than information kept in RAM (RAM is superior in terms of speed owing to its architecture), but the operating system will prefer to keep running application data in memory and only use the swap for the older data. Essentially, having swap space as a failsafe for when your system’s physical memory is depleted can be a good safety net against crashes on systems with non-SSD storage available.

    Determine the size of the Swap we actually need.

    This process is made so much easier by using the below calculator

    https://pickwicksoft.github.io/swapcalc/

    Admittedly, if you only had 1Gb RAM, the SWAP would be default at 1Gb. You can play with the various configurations here to get the results you need, but be honest - don’t make your system out to be something it isn’t, because otherwise, you’ll create more problems than you set out to resolve.

    Swap space refers to a designated portion of hard drive storage that’s reserved for temporary data storage by the operating system when the RAM can’t accommodate it any longer. This allows for an expansion of the data that your server can hold in its active memory, though with certain conditions. The swap area on the hard drive comes into play primarily when there isn’t enough room left in the RAM to hold active application data.

    The data that gets written to the disk is notably slower than the data stored in RAM. Nevertheless, the operating system prioritizes keeping currently used application data in memory and employs swap for older data. Having swap space as a fallback when your system’s RAM is exhausted can serve as a valuable safeguard against out-of-memory errors, especially on systems with traditional non-SSD storage.

    Verifying the System for Swap Information

    Before proceeding, it’s advisable to confirm whether your system already has existing swap space. While it’s possible to have multiple swap files or swap partitions, typically one should suffice.

    You can check if your system has any configured swap by executing:

    sudo swapon --show

    If you receive no output, it means your system presently lacks swap space.

    You can also confirm the absence of active swap using the free utility:

    free -h

    As evident in the output, there is no active swap on the system, as shown in the Swap row.

    total used free shared buff/cache available Mem: 981Mi 122Mi 647Mi 0.0Ki 211Mi 714Mi SWAP: 0B 0B 0B Assessing Available Space on the Hard Drive Partition

    Before creating a swap file, it’s essential to check the current disk usage to ensure you have enough available space. This can be done by entering

    df -h Filesystem Size Used Avail Use% Mounted on tmpfs 1.6G 876K 1.6G 1% /run /dev/sda1 150G 65G 80G 45% / tmpfs 7.7G 0 7.7G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock /dev/sda15 253M 6.1M 246M 3% /boot/efi tmpfs 1.6G 0 1.6G 0% /run/user/1009

    The device with / in the Mounted on column is our disk in this case. We have sufficient remaining space available - 65G used. Your availability will obviously be different.

    The appropriate size of a swap space can vary according to personal preferences and application requirements. Typically, an amount equivalent to or double the system’s RAM is a good starting point. For a simple RAM fallback, anything over 4G of swap is usually deemed unnecessary.

    Creating a Swap File

    Now that you’ve determined the available hard drive space, you can generate a swap file on your file system. A file of your desired size, named ‘swapfile,’ will be allocated in your root directory (/).

    The recommended method for creating a swap file is by using the fallocate program, which instantly generates a file of the specified size. For instance, if your server has 1G of RAM, you can create a 1G file as follows:

    sudo fallocate -l 1G /swapfile

    You can confirm the correct space allocation by running:

    ls -lh /swapfile

    The file will be created with the appropriate space allocation.

    Activating the Swap File

    Now that you have a correctly sized file, it’s time to turn it into swap space. Initially, you must restrict file access to only root users, enhancing security. To achieve this, execute:

    sudo chmod 600 /swapfile

    You can verify the permission change with:

    ls -lh /swapfile

    As seen in the output, only the root user has read and write permissions.

    Next, mark the file as swap space with:

    sudo mkswap /swapfile

    Afterward, enable the swap file to allow your system to utilize it:

    sudo swapon /swapfile

    You can verify the availability of swap by executing:

    sudo swapon --show

    Finally, recheck the output of the free utility to confirm the setup:

    free -h Making the Swap File Permanent

    The changes made enable the swap file for the current session, but they won’t persist through a system reboot. To ensure your swap settings remain, you can add the swap file information to your /etc/fstab file. Here’s how you can do it:

    Back up the /etc/fstab file as a precaution:

    sudo cp /etc/fstab /etc/fstab.bak

    Add the swap file information to the end of your /etc/fstab file with:

    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab Adjusting Swap Settings

    There are several settings you can configure to influence your system’s performance with swap. Two key settings are the swappiness property and the cache pressure setting:

    Swappiness Property: This parameter determines how often data is swapped from RAM to the swap space. A value between 0 and 100 represents a percentage. Lower values (close to 0) mean less frequent swapping, while higher values (closer to 100) encourage more swapping. You can check the current swappiness value with:

    cat /proc/sys/vm/swappiness

    You can set a different value using the sysctl command. For example, to set the swappiness to 10:

    sudo sysctl vm.swappiness=10

    This setting persists until the next reboot, but you can make it permanent by adding it to your /etc/sysctl.conf file.

    Cache Pressure Setting: This setting affects how the system caches inode and dentry information over other data. Lower values, like 50, make the system cache this information more conservatively. You can check the current cache pressure value with:

    cat /proc/sys/vm/vfs_cache_pressure

    To set a different value, use the sysctl command and update your /etc/sysctl.conf file as you did with the swappiness setting.

  • Get help with network issues

    4 Topics
    273 Posts

    @phenomlab Found it - https://www.netspotapp.com/wifi-troubleshooting/best-wifi-booster-apps.html 👍

  • nodebb loading emojis

    Solved
    16
    1 Votes
    16 Posts
    462 Views

    @DownPW sure. Let me have a look at this in more detail. I know nginx plus has extensive support for this, but it’s not impossible to get somewhere near acceptable with the standard version.

    You might be better off handling this at the Cloudflare level given that it sits in between the requesting client and your server.

  • Email Server Settings

    Solved
    23
    8 Votes
    23 Posts
    1k Views

    @Madchatthew mailgun would be my recommendation here. I think they also have a free plan if I’m not mistaken.

  • DNS to Point Domain Name to

    Solved
    13
    3 Votes
    13 Posts
    411 Views

    @Madchatthew good luck 😃

  • Chevron up before & after

    Solved
    11
    4 Votes
    11 Posts
    379 Views

    @crazycells you are right 🙂 thank you.

  • Issues with v3 alpha and Harmony

    Moved Solved
    18
    4 Votes
    18 Posts
    413 Views

    @cagatay Should be all sorted now 🙂
    Don’t forget to put your language back to Turkish.

  • Issues getting Flarum to work on new host

    Solved
    65
    14 Votes
    65 Posts
    5k Views

    @crazycells huh. Thanks. Will need to check that as well.

  • 3 Votes
    2 Posts
    135 Views

    @DownPW This isn’t something I have readily available, and because I’m not entirely familiar with the database structure of NodeBB, it’s something that would require research and development in terms of script.

    I think it’d be quicker to ask this in the NodeBB forums.

  • 5 Votes
    13 Posts
    488 Views
    'use strict'; const winston = require('winston'); const user = require('../user'); const notifications = require('../notifications'); const sockets = require('../socket.io'); const plugins = require('../plugins'); const meta = require('../meta'); module.exports = function (Messaging) { Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser Messaging.notifyUsersInRoom = async (fromUid, roomId, messageObj) => { let uids = await Messaging.getUidsInRoom(roomId, 0, -1); uids = await user.blocks.filterUids(fromUid, uids); let data = { roomId: roomId, fromUid: fromUid, message: messageObj, uids: uids, }; data = await plugins.hooks.fire('filter:messaging.notify', data); if (!data || !data.uids || !data.uids.length) { return; } uids = data.uids; uids.forEach((uid) => { data.self = parseInt(uid, 10) === parseInt(fromUid, 10) ? 1 : 0; Messaging.pushUnreadCount(uid); sockets.in(`uid_${uid}`).emit('event:chats.receive', data); }); if (messageObj.system) { return; } // Delayed notifications let queueObj = Messaging.notifyQueue[`${fromUid}:${roomId}`]; if (queueObj) { queueObj.message.content += `\n${messageObj.content}`; clearTimeout(queueObj.timeout); } else { queueObj = { message: messageObj, }; Messaging.notifyQueue[`${fromUid}:${roomId}`] = queueObj; } queueObj.timeout = setTimeout(async () => { try { await sendNotifications(fromUid, uids, roomId, queueObj.message); } catch (err) { winston.error(`[messaging/notifications] Unabled to send notification\n${err.stack}`); } }, meta.config.notificationSendDelay * 1000); }; async function sendNotifications(fromuid, uids, roomId, messageObj) { const isOnline = await user.isOnline(uids); uids = uids.filter((uid, index) => !isOnline[index] && parseInt(fromuid, 10) !== parseInt(uid, 10)); if (!uids.length) { return; } if (roomId != 11) { // 5 Is the ID of the ID of the global chat room. Messaging.getUidsInRoom(roomId, 0, -1); // Proceed as normal. } else { user.getUidsFromSet('users:online', 0, -1); // Only notify online users. } const { displayname } = messageObj.fromUser; const isGroupChat = await Messaging.isGroupChat(roomId); const notification = await notifications.create({ type: isGroupChat ? 'new-group-chat' : 'new-chat', subject: `[[email:notif.chat.subject, ${displayname}]]`, bodyShort: `[[notifications:new_message_from, ${displayname}]]`, bodyLong: messageObj.content, nid: `chat_${fromuid}_${roomId}`, from: fromuid, path: `/chats/${messageObj.roomId}`, }); delete Messaging.notifyQueue[`${fromuid}:${roomId}`]; notifications.push(notification, uids); } };
  • Nodebb: failed to restore a mongo dump

    Solved
    2
    1 Votes
    2 Posts
    157 Views

    @phenomlab

    In fact I specified the sub rep and not the rep

    DON’T DO THIS:

    nodebb@nodebbpwclonedb:~/nodebb$ sudo mongorestore --username admin --password XXXXXXXXXXXXXX --nsInclude nodebb.objects --drop /home/nodebb/nodebb_DB_20230107/nodebb/

    BUT THIS :

    nodebb@nodebbpwclonedb:~/nodebb$ sudo mongorestore --username admin --password XXXXXXXXXXXXXX --nsInclude nodebb.objects --drop /home/nodebb/nodebb_DB_20230107/

    🙂

  • 2 Votes
    19 Posts
    577 Views

    @phenomlab Work now 😉

  • restarting nodebb on boot

    Unsolved
    3
    1 Votes
    3 Posts
    218 Views

    @eeeee said in restarting nodebb on boot:

    can I just run nodebb under nodemon for auto restarts?

    It’s a better method. Nodemon just looks for file system changes and would effectively die if the server was rebooted meaning you’d have to start it again anyway. Systemd is the defacto standard which is how the operating system interacts in terms of services, scheduled tasks etc.

  • Recent Cards Plugin

    Solved
    5
    4 Votes
    5 Posts
    248 Views

    @crazycells that’s a good point. Thanks

  • 24 Votes
    29 Posts
    4k Views

    @DownPW it is the second post of this thread.

  • Gettin Erors NodeBB

    Solved
    7
    0 Votes
    7 Posts
    325 Views

    @phenomlab no forum is working goods.
    there is no eror message since yestarday.

  • Where to add to DNS settings for Google crawl

    Solved
    4
    1 Votes
    4 Posts
    193 Views

    @eveh yes, as the DNS will be natively registered there.

  • MailGun Not Working NodeBB

    Solved
    6
    1 Votes
    6 Posts
    245 Views

    @phenomlab did it 🙂 i did not create smtp user on mailgun. everything is working now.

    6cc6061f-ed5d-41f6-8eb7-5d98f98b3706-image.png

  • Podcast Share NodeBB

    Solved
    15
    4 Votes
    15 Posts
    482 Views

    @cagatay You could experiment with nodebb-plugin-ns-embed but I expect the x-origin tag on the remote site to prevent playback.

  • Rotating homepage icons, gifs?

    Solved
    2
    3 Votes
    2 Posts
    194 Views

    @eveh It’s not a GIF, no. It’s actually a webp file so made much smaller, and uses keyframes to control the rotation on hover. You can easily make your own though 🙂

    The CSS for that is as below

    @keyframes rotate180 { from { transform: rotate(0deg); } to { transform: rotate(180deg); } } @keyframes rotate0 { from { transform: rotate(180deg); } to { transform: rotate(0deg); } }

    Your milage may vary on the CSS below, as it’s custom for Sudonix, but this is the class that is used to control the rotate

    .header .forum-logo, img.forum-logo.head { max-height: 50px; width: auto; height: 30px; margin-top: 9px; max-width: 150px; min-width: 32px; display: inline-block; animation-name: rotate180, rotate0; animation-duration: 1000ms; animation-delay: 0s, 1000ms; animation-iteration-count: 1; animation-timing-function: linear; transition: transform 1000ms ease-in-out; }
  • Adding fileWrite to nodebb code

    Solved
    16
    5 Votes
    16 Posts
    589 Views

    @eveh this might be a question for the NodeBB Devs themselves. In all honesty, I’m not entirely sure without having to research this myself.

  • 6 Votes
    36 Posts
    2k Views

    @justoverclock said in Digitalocean step by step guide to nginx configuration:

    i’m learning

    And that’s the whole point of this site 🙂 If you don’t learn anything, you gain nothing.