Reference article: Waline Comment System - Deployment Logs | CC's Blog
Updated on September 5, 2023
Tencent Cloud changed the payment model for CloudBase, and the minimum monthly payment is now 19.9, which is close to 20 times the cost of maintaining my blog. So I migrated my service to Alibaba Cloud's Function Compute, and it is currently running stable.
Updated on August 10, 2021
Due to the delayed upgrade of Waline version, the HTML code for emoji images was escaped. Therefore, it is necessary to modify the version number inpackage.json
of@waline/cloudbase
, which is currently 1.0.25. After the modification, it can be used normally.
Introduction#
After migrating the blog to static pages, finding an embeddable third-party commenting system became something I needed to consider, as Gitalk and Discuz were almost unusable due to network issues. After extensive use and experimentation, Sohu's Changyan did not perform well on the blog, and Valine had been heavily spammed with junk comments before, so I dared not use it. Therefore, I finally settled on Waline, which is described as a Valine with a backend, so it has a series of usable features.
This article will not go into detail about the introduction of Waline, you can check the official documentation for that. This article also does not involve installation methods like Velcel+Leancloud, you can check the reference article above. This article briefly describes the deployment process, mainly focusing on the steps I took and the exploration of some features.
Deployment Process#
Claiming Free Resources#
According to the reference article, scroll down on this page and you will see the familiar "0 yuan" (free) offer. After purchasing, enter the environment name.
Setting Up Cloud Functions#
In the purchased environment details page, click "Cloud Functions - Create Cloud Function" to create the required cloud functions, with the runtime environment and maximum memory as shown in the image:
In the next step, replace part of the function code with the following:
module.exports.main = async (event, context) => {
context.callbackWaitsForEmptyEventLoop = false;
const entry = (() => {
const result = require('./app.js');
// const app = require('express')();
// result = app.use(result);
return result;
})();
const serverless = require('serverless-http');
let app = entry;
// support for async load app
if (entry && entry.tcbGetApp && typeof entry.tcbGetApp === 'function') {
app = await entry.tcbGetApp();
}
return serverless(app, {
binary: [
'application/javascript',
'application/octet-stream',
'application/xml',
'font/eot',
'font/opentype',
'font/otf',
'image/*',
'video/*',
'audio/*',
'text/comma-separated-values',
'text/css',
'text/javascript',
'text/plain',
'text/text',
'text/xml',
],
})(event, context);
};
Then, move the app.js
, cloudbaserc.json
, and package.json
files from this repository as they are, and click "Save and Install Dependencies" to complete the process, as shown in the image below:
HTTP Access#
If you want to access the application, it is recommended to bind your own domain name and enable HTTPS, as shown in the image below:
After configuring, it should look like the image below:
After configuring the domain name, set the secure domain in "Security Configuration", as shown in the image below:
Environment Variables#
Unlike deploying to a pay-as-you-go environment in CloudBase, in manual deployment, you set the environment variables in "Cloud Functions", as shown in the image below:
Click "Edit" in the upper right corner, add the corresponding environment variables and their values, and after saving, the application will have the corresponding functionality.
Configuring Email Notifications#
Since ZOHO's SMTP service is only available to paid users, I moved the entire email service to Tencent Enterprise Mail, and also set up an email account for sending notifications.
Use the environment variables provided in the official documentation, as shown in the image below:
Where SMTP_USER
and SMTP_PASS
are the account and password for the email. For details on configuring enterprise email, see this article, which is similar, or follow the instructions provided, which is also very simple.
After configuring, perform a test and successfully send an email:
Conclusion#
Using Waline successfully solved the commenting problem on the blog. I struggled with the email notification part of the comments for a long time, from SendGrid to SendCloud and finally to Tencent Enterprise Mail, and finally implemented this feature. From now on, I no longer have to worry about not replying to comments in a timely manner.