hack-chat / main

a minimal, distraction-free chat application
https://hack.chat/
1.31k stars 222 forks source link

How to host a mirror page on public web? #166

Closed Programmer1603 closed 2 years ago

Programmer1603 commented 2 years ago

I already tried the local installation and everything worked out great! Does smb know how to host it on the public web? If so please help me. Thank you in advance. ~Programmer1603

AnnikaV9 commented 2 years ago

You'll need to set up either one of these:

Or deploy a server instance on a platform like DigitalOcean or Vultr

Programmer1603 commented 2 years ago

Ok thank you i will try it asap

Programmer1603 commented 2 years ago

hey.... its me again.... i am still unable to deploy it: i get this error on digitalocean: ┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐ │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │ ├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤ │ 0 │ hackchat │ default │ 2.1.93 │ fork │ 0 │ 0 │ 15 │ errored │ 0% │ 0b │ root │ disabled │ └─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴���─────┴───────────┴──────────┴──────────┴──────────┴──────────┘

and the app function of digitalocean fails while booting if i use this repo as base...... Can smb explain it to me simple? Like i am a 5 year old? I am not a skiddie or anything, but it looks like i am way to stupid to use this. Digitalocean gives everybody 100$ free cradit if smb wants to help. Thank you again...... Have a nice day and please help me. it really drives me insane.

marzavec commented 2 years ago

Does smb know how to host it on the public web?

At first I started trying to figure out how SMB could be used to bridge HTTP- maybe some kind of local WebDAV server routing through CIFS/SMB. But then I realized that you are attempting to save a millisecond and five keystrokes by abbreviating the word "somebody". . .

You can see on the pm2 status screen, it states the process has errored. PM2 keeps logs, which you can access by running npm run logs or checking the log files in your home directory, under .pm2. Let use know what the error is.

Programmer1603 commented 2 years ago

[2022-05-02 15:55:12] > hack.chat-v2@2.1.93 start [2022-05-02 15:55:12] > pm2 startOrReload pm2.config.js [2022-05-02 15:55:12] [2022-05-02 15:55:13] [2022-05-02 15:55:13] ------------- [2022-05-02 15:55:13] [2022-05-02 15:55:13] /\\\\\\_/\\____/\\____/\\\\\ [2022-05-02 15:55:13] \/\\/////////\_\/\\\____/\\\_/\\///////\_ [2022-05-02 15:55:13] \/\____\/\_\/\\//\_/\\//\\\///____\//\_ [2022-05-02 15:55:13] \/\\\\\\\/\/\\///\\/\\/\/\____/\\/ [2022-05-02 15:55:13] \/\\/////////__\/\__\///\\/_\/\_____/\\// [2022-05-02 15:55:13] \/\_____\/\__\///__\/\_/\\//____ [2022-05-02 15:55:13] \/\_____\/\_____\/\_/\\/____ [2022-05-02 15:55:13] \/\_____\/\_____\/\_/\\\\\\\_ [2022-05-02 15:55:13] _\///__\///__\///\/////////////// [2022-05-02 15:55:13] [2022-05-02 15:55:13] [2022-05-02 15:55:13] Runtime Edition [2022-05-02 15:55:13] [2022-05-02 15:55:13] PM2 is a Production Process Manager for Node.js applications [2022-05-02 15:55:13] with a built-in Load Balancer. [2022-05-02 15:55:13] [2022-05-02 15:55:13] Start and Daemonize any application: [2022-05-02 15:55:13] $ pm2 start app.js [2022-05-02 15:55:13] [2022-05-02 15:55:13] Load Balance 4 instances of api.js: [2022-05-02 15:55:13] $ pm2 start api.js -i 4 [2022-05-02 15:55:13] [2022-05-02 15:55:13] Monitor in production: [2022-05-02 15:55:13] $ pm2 monitor [2022-05-02 15:55:13] [2022-05-02 15:55:13] Make pm2 auto-boot at server restart: [2022-05-02 15:55:13] $ pm2 startup [2022-05-02 15:55:13] [2022-05-02 15:55:13] To go further checkout: [2022-05-02 15:55:13] http://pm2.io/ [2022-05-02 15:55:13] [2022-05-02 15:55:13] [2022-05-02 15:55:13] ------------- [2022-05-02 15:55:13] [2022-05-02 15:55:14] [PM2] Spawning PM2 daemon with pm2_home=/workspace/.pm2 [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency [2022-05-02 15:55:14] (Use node --trace-warnings ... to show where the warning was created) [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'find' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'head' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'set' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'test' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'to' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency [2022-05-02 15:55:14] (node:17) Warning: Accessing non-existent property 'which' of module exports inside circular dependency [2022-05-02 15:55:14] [PM2] This PM2 is not UP TO DATE [2022-05-02 15:55:14] [PM2] Upgrade to version 5.2.0 [2022-05-02 15:55:14] [PM2] PM2 Successfully daemonized [2022-05-02 15:55:14] [PM2][WARN] Applications hackchat-websocket, hackchat-httpd not running, starting... [2022-05-02 15:55:14] [PM2] App [hackchat-websocket] launched (1 instances) [2022-05-02 15:55:14] [PM2] App [hackchat-httpd] launched (1 instances) [2022-05-02 15:55:15] ┌─────┬───────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐ [2022-05-02 15:55:15] │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │ [2022-05-02 15:55:15] ├─────┼───────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤ [2022-05-02 15:55:15] │ 1 │ hackchat-httpd │ default │ 0.12.1 │ fork │ 45 │ 0s │ 0 │ online │ 0% │ 0b │ apps │ disabled │ [2022-05-02 15:55:15] │ 0 │ hackchat-websocket │ default │ 2.1.93 │ fork │ 39 │ 0s │ 0 │ online │ 0% │ 0b │ apps │ disabled │ [2022-05-02 15:55:15] └─────┴───────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘ [2022-05-02 15:55:15] npm notice [2022-05-02 15:55:15] npm notice New minor version of npm available! 8.5.5 -> 8.8.0 [2022-05-02 15:55:15] npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.8.0 [2022-05-02 15:55:15] npm notice Run npm install -g npm@8.8.0 to update! [2022-05-02 15:55:15] npm notice []

Programmer1603 commented 2 years ago

This is my full error log of the deployment The build has been sucesfull, so i didnt provide the logs here....

Programmer1603 commented 2 years ago

Do you know how to fix this?

marzavec commented 2 years ago

No errors are listed in this log. Did you open this from the ~/.pm2/logs directory? If so, then you need to open the log file that ends with "-error.log". . .

Programmer1603 commented 2 years ago

Oh i am still using digital ocean and it wont let you use console once a error occured... at least afaik

Should i try to host it somewhere else? I would probably host it as a tor hidden service...

AnnikaV9 commented 2 years ago

You can still host it on DigitalOcean, but use their Droplets instead of the App Platform. You have full access within your droplets, so you can see any logs you need.

Programmer1603 commented 2 years ago

Ok i will try that and i will get in touch with you in a few hours. Thank you very much

Programmer1603 commented 2 years ago

Now i did use a dropplet, but:

[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option) /root/.pm2/pm2.log last 15 lines: PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] online PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] exited with code [1] via signal [SIGINT] PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] starting in -fork mode- PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] online PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] exited with code [1] via signal [SIGINT] PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] starting in -fork mode- PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] online PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] exited with code [1] via signal [SIGINT] PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] starting in -fork mode- PM2 | 2022-05-04T14:06:03: PM2 log: App [hackchat:0] online PM2 | 2022-05-04T14:06:04: PM2 log: App [hackchat:0] exited with code [1] via signal [SIGINT] PM2 | 2022-05-04T14:06:04: PM2 log: App [hackchat:0] starting in -fork mode- PM2 | 2022-05-04T14:06:04: PM2 log: App [hackchat:0] online PM2 | 2022-05-04T14:06:04: PM2 log: App [hackchat:0] exited with code [1] via signal [SIGINT] PM2 | 2022-05-04T14:06:04: PM2 log: Script /hackchat/server/main.js had too many unstable restarts (16). Stopped. "errored"

/root/.pm2/logs/hackchat-out.log last 15 lines: /root/.pm2/logs/hackchat-error.log last 15 lines: 0|hackchat | at preloadModules (internal/bootstrap/node.js:602:7) 0|hackchat | at startup (internal/bootstrap/node.js:273:9) 0|hackchat | at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3) 0|hackchat | internal/modules/cjs/loader.js:638 0|hackchat | throw err; 0|hackchat | ^ 0|hackchat | 0|hackchat | Error: Cannot find module 'esm' 0|hackchat | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) 0|hackchat | at Function.Module._load (internal/modules/cjs/loader.js:562:25) 0|hackchat | at Module.require (internal/modules/cjs/loader.js:692:17) 0|hackchat | at Module._preloadModules (internal/modules/cjs/loader.js:901:12) 0|hackchat | at preloadModules (internal/bootstrap/node.js:602:7) 0|hackchat | at startup (internal/bootstrap/node.js:273:9) 0|hackchat | at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

marzavec commented 2 years ago

Looks like you're missing some modules for some reason, maybe you haven't run the install command?

Out of curiosity, I spun up a new droplet just now and followed the deployment instructions; https://github.com/hack-chat/main/blob/master/documentation/DEPLOY.md and, besides being out of date, everything worked fine.

Move into the server directory and run npm run install and then npm run config.

Programmer1603 commented 2 years ago

i tired to run the install command but this happend: npm ERR! missing script: install

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-05-05T11_35_26_716Z-debug.log

Debug log: info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'install' ] 2 info using npm@6.14.12 3 info using node@v10.24.1 4 verbose stack Error: missing script: install 4 verbose stack at run (/usr/lib/node_modules/npm/lib/run-script.js:155:19) 4 verbose stack at /usr/lib/node_modules/npm/lib/run-script.js:63:5 4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:116:5 4 verbose stack at /usr/lib/node_modules/npm/nodemodules/read-package-json/read-json.js:436:5 4 verbose stack at checkBinReferences (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:391:45) 4 verbose stack at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:434:3) 4 verbose stack at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:161:5) 4 verbose stack at ReadFileContext. (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:350:20) 4 verbose stack at ReadFileContext.callback (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:123:16) 4 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13) 5 verbose cwd /root/main/server 6 verbose Linux 5.4.0-107-generic 7 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "install" 8 verbose node v10.24.1 9 verbose npm v6.14.12 10 error missing script: install 11 verbose exit [ 1, true ]

marzavec commented 2 years ago

Oh, sorry, I meant npm install

Programmer1603 commented 2 years ago

Np, But as far asi i am able to remember i did npm install...

AnnikaV9 commented 2 years ago

hmm, not sure why npm is trying to find an install script instead of reading the package.json

Can you try running something like npm install pm2 and see if it works?

Programmer1603 commented 2 years ago

Sorry i have been busy the last two days, i will try it tomorrow night in like 20h or smth. Is there a possibility for you to make a deploy to heroku button or smth like that?

Thank you for helping and your great work! I am really grateful for friendly developers, like you guys are! Keep up the work!

AnnikaV9 commented 2 years ago

There's no reason hack.chat wouldnt work in a regular droplet, so I think it's better to find and solve the problem rather than avoiding it. I suspect a broken install of npm, but I have never experienced this weird behaviour of npm. Which droplet image did you use?

I ran various podman containers and installed hack.chat successfully:

Installing dependencies:

# Debian Bullseye
sudo apt update
sudo apt full-upgrade
sudo apt install git nodejs npm

# Arch Linux
sudo pacman -Syu git nodejs npm

# Fedora 35
sudo yum update
sudo yum install git nodejs npm

# Alpine Linux 3.15
sudo apk update
sudo apk upgrade
sudo apk add git nodejs npm

Then:

git clone https://github.com/hack-chat/main hack.chat
cd hack.chat
npm install
Programmer1603 commented 2 years ago

I used ubuntu 20.xx I will just try a different image then i guess.... Thanks

Programmer1603 commented 2 years ago

Thank you i think it worked now i just configured it whit the hack.chat wizard, but how am i able to access the web page? I tried to connect trough a normal browser via the ip, it didnt work........

AnnikaV9 commented 2 years ago

You can either:

...
name: 'hackchat-httpd', 
script: './node_modules/http-server/bin/http-server', 
args: './client -p 3000 -o',
...

to

...
name: 'hackchat-httpd',
script: './node_modules/http-server/bin/http-server',
args: './client -p 80 -o',
...

and you should be able to access it without having to specify the port in the address bar

Programmer1603 commented 2 years ago

Thank you for your quick response, i think i will use nginx....

Programmer1603 commented 2 years ago

I am now running nginx and the default site is reachable. However do i have to copy the index.html from the client folder or change the default nginx folder?

Edit: i copied the entire /client folder in the nginx folder and the ui works perfectly I can change the url with ip.ip.ip.ip/?my-chatroom to enter a chatroom, but i am still not able to chat.... I can type in the textbox, but I cant send anything or see snt messages, also the chatroom GUI doesn´t look right...

AnnikaV9 commented 2 years ago

Did you start the backend server?

pm2 start ./server/main.js --node-args="-r esm" --name hackchat
Programmer1603 commented 2 years ago

Now its fully operational. Thank you so much! If i get weird errors or smth i will open a new issue! Have a nice day! ~Programmer1603