Skip to content

Commit

Permalink
Updates scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Feb 29, 2024
1 parent c9ab499 commit 37201a7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
4 changes: 4 additions & 0 deletions app/views/examples/folders/folder.html
Expand Up @@ -4,4 +4,8 @@

<p><a href="https://github.com/davidmerfield/Blot/tree/master/app/templates/folders/{{slug}}">View source</a></p>

<p>This is a self-contained stand-alone site. If you <a href="{{#cdn}}{{{zip}}}{{/cdn}}"></a>download this folder</a> and place its contents in your own site's folder, you will get the same site. </p>

<p>Unlike Blot's <a href="/examples/templates">templates</a> which are general-purpose, this folder contain a template which is specific to the content in the folder.</p>

{{/folder}}
4 changes: 4 additions & 0 deletions app/views/examples/folders/index.html
@@ -1,3 +1,7 @@
<h1>Folders</h1>

<p>These are self-contained stand-alone sites built with Blot. If you download one of these folders and place its contents in your own site's folder, you will get the same site. </p>

<p>Unlike Blot's <a href="/examples/templates">templates</a> which are general-purpose, these folders contain a template which is specific to the content in the folder.</p>

{{> folder-list}}
2 changes: 1 addition & 1 deletion config/index.js
Expand Up @@ -47,7 +47,7 @@ module.exports = {
port: BLOT_PORT,
clients_port: 8888,

redis: { port: 6379, host: process.env.BLOT_REDIS_HOST },
redis: { port: 6379, host: process.env.BLOT_REDIS_HOST || "127.0.0.1" },

admin: {
uid: process.env.BLOT_ADMIN_UID,
Expand Down
2 changes: 1 addition & 1 deletion scripts/access.js
Expand Up @@ -38,7 +38,7 @@ function main (handle, callback) {
var url = format({
protocol: "https",
host: config.host,
pathname: "/log-in",
pathname: "/dashboard/log-in",
query: {
token: token
}
Expand Down
44 changes: 16 additions & 28 deletions scripts/state/load.js
Expand Up @@ -2,8 +2,7 @@ require("../only_locally");

var fs = require("fs-extra");
var exec = require("child_process").exec;
var redis = require("redis");
var ROOT = process.env.BLOT_DIRECTORY;
var ROOT = require("config").blot_directory;

var DATA_DIRECTORY = ROOT + "/data";

Expand All @@ -15,35 +14,24 @@ async function main (label, callback) {
if (!fs.existsSync(directory))
return callback(new Error("No state " + label));

var client = redis.createClient();
var multi = client.multi();
exec("docker-compose stop node-app", { silent: true }, function (err) {
if (err) return callback(err);
exec("docker-compose stop redis", { silent: true }, function (err) {
if (err) return callback(err);

// If redis was already shut down, then
// we won't be able to execute the multi()
client.on("error", function (err) {
if (err.code === "ECONNREFUSED") {
then();
}
});

multi.config("SET", "appendonly", "no").config("SET", "save", "").shutdown();

multi.exec(then);
fs.emptyDirSync(DATA_DIRECTORY);
fs.ensureDirSync(directory + "/data");
fs.copySync(directory + "/data", DATA_DIRECTORY);

function then () {
fs.emptyDirSync(DATA_DIRECTORY);
fs.ensureDirSync(directory + "/data");
fs.copySync(directory + "/data", DATA_DIRECTORY);

exec(
"redis-server --daemonize yes --dir " + ROOT + "/data",
{ silent: true },
function (err) {
exec("docker-compose start redis", { silent: true }, function (err) {
if (err) return callback(err);
callback(null);
}
);
}
exec("docker-compose start node-app", { silent: true }, function (err) {
if (err) return callback(err);
setTimeout(callback, 5000);
});
});
});
});
}

if (require.main === module) {
Expand Down

0 comments on commit 37201a7

Please sign in to comment.