Timeout, package and docs cleanup

This commit is contained in:
Pitu 2020-07-18 02:21:31 +09:00
parent 695d9a74ef
commit 2d06d918a1
6 changed files with 24 additions and 28 deletions

View File

@ -8,33 +8,28 @@
This guide asumes a lot of things, including that you know your way around linux, nginx and internet in general.
- Decently updated version of linux
- `node` package installed and at least at version 10
- `build-essential` package installed to build some dependencies
- `ffmpeg` package installed if you want thumbnails
- `node` version 12+
- `build-essential` package installed to build dependencies
- `ffmpeg` package installed if you want video thumbnails
- `yarn` package installed. If you'd like to use npm instead change `package.json` accordingly
- A database, postgresql preferably. You can also fall back to sqlite3 by default.
- `pm2` globally installed (`npm i -g pm2`) to keep the service alive at all times.
- A database, postgresql preferably. You can also fall back to sqlite3 which ships by default.
### Installing
1. Clone the repository and `cd` into it
2. Run `yarn install`
3. Run `yarn setup`
4. Run `yarn migrate`
5. Run `yarn seed`
Lolisafe is now installed, configured and ready. Now you need to serve it to the public by using a domain name.
6. Check the [nginx](docs/nginx.md) file for a sample configuration that has every step to run lolisafe securely on production.
After you finish setting up nginx, you need to start lolisafe by using pm2. If you want to use something else, figure out how. (More info on why pm2 [here](docs/pm2.md))
After you finish setting up nginx, you need to start lolisafe by using pm2. If you want to use something else like forever, ensure that the process spawned from `npm run start` never dies.
7. Run `pm2 start pm2.json`:
8. Profit
### Cloudflare
If you want to run your site through CloudFlare because of the obvious advantages it has, lolisafe has your back. Unless you manually modify the `.env` file, uploads through the website will be uploaded in chunks thus bypassing CloudFlare's 100mb upload limit per file.
## Author
**lolisafe** © [Pitu](https://github.com/Pitu), Released under the [MIT](https://github.com/WeebDev/lolisafe/blob/master/LICENSE) License.<br>

14
docs/migrating.md Normal file
View File

@ -0,0 +1,14 @@
### Migrate from v3 to v4
This version introduces a few breaking changes and updating requires some manual work.
For starters we recommend cloning the new version somewhere else instead of `git pull` on your v3 version.
- After cloning move your `uploads` folder from the v3 folder to the new v4 folder.
- Then copy your `database/db` file from your v3 folder to the root of your v4 folder.
- You then need to run `yarn setup` or `npm start setup` from the v4 folder and finish the setup process.
- Once that's done you need to manually run `node src/api/databaseMigration.js` from the root folder of v4
- After the migration finishes, the last step is to update your nginx config with the [newly provided script](./nginx.md)
- Restart nginx with `sudo nginx -s reload`
- And lastly start your lolisafe instance with `pm2 start pm2.json`
### Known issues of migrating
- The thumbnails in the album view don't show up. That's because they don't exist, this will get solved as you upload new stuff so the newly uploaded files get the proper thumbnail created.

View File

@ -1,11 +0,0 @@
## Setting up PM2 to run lolisafe
The best way to keep the service running in case of crashes or unexpected issues is to attach the process to PM2 and forget about it. This also gives you the ability to dettach the process from your terminal and run it in the background, which is a must since lolisafe now comes in 2 separate processes.
The recommended way to set it up is to run the commands below, one for the API and the other for the site.
```
pm2 start npm --name "lolisafe-api" -- run api
pm2 start npm --name "lolisafe-site" -- run site
```
All set, if you want to check the logs you can `pm2 logs lolisafe-api` or similar.

View File

@ -8,7 +8,6 @@
"email": "heyitspitu@gmail.com",
"url": "https://github.com/Pitu"
},
"main": "src/_scripts/start.js",
"scripts": {
"setup": "node src/setup.js && yarn build && yarn migrate && yarn seed",
"build": "nuxt build",
@ -18,7 +17,7 @@
"seed": "yarn knex seed:run",
"api": "node src/api/structures/Server",
"update": "git pull && yarn install && yarn migrate && yarn build && yarn restart",
"restart": "pm2 restart lolisafe-api && pm2 restart lolisafe-website"
"restart": "pm2 restart lolisafe"
},
"repository": {
"type": "git",
@ -28,7 +27,7 @@
"url": "https://github.com/WeebDev/lolisafe/issues"
},
"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
},
"dependencies": {
"@nuxtjs/axios": "^5.4.1",

View File

@ -78,9 +78,10 @@ class Server {
jetpack.dir('uploads/thumbs/square');
this.registerAllTheRoutes();
this.serveNuxt();
this.server.listen(this.port, () => {
const server = this.server.listen(this.port, () => {
log.success(`Backend ready and listening on port ${this.port}`);
});
server.setTimeout(600000);
}
}

View File

@ -155,8 +155,6 @@ async function start() {
console.log('=============================================');
console.log('== .env file generated successfully. ==');
console.log('=============================================');
console.log('== Run `yarn migrate` and `yarn seed` next ==');
console.log('=============================================');
console.log();
}