netbymatt / ws4kp

WeatherStar 4000+
https://weatherstar.netbymatt.com
MIT License
273 stars 47 forks source link

Setting up on Linux shared host #31

Closed mmarron79 closed 9 months ago

mmarron79 commented 11 months ago

I'm trying to set this up on a shared Linux host. I keep getting a 404 error. My host's tech support says I have the application setup correctly, and that it must be a coding error. I tried Node versions 12.22.9 and 14.21.2. I also tried development and production modes. Nothing changes. The readme mentions running it on a local machine, but not on a web host, so I feel like I'm missing a step. Please advise.

Matt

netbymatt commented 11 months ago

There's a lot of pieces to hosting this that need to fall into place. They're all more under the scope of "hosting a nodejs app on shared hosting" of which there an and endless number of guides available.

Here are the general pieces to getting it done. Any one of which would cause problems with it running successfully.

mmarron79 commented 11 months ago

I created the app in cpanel. As far as I know, it runs all the time and uses port 80. The domain uses https. Since I didn't set it up through SSH, I didn't realize I had to install other packages (I'm not new to javascript, but am new to Node). It appears the issue is with installing the packages. My host says some packages (mentioned in package.json I assume) are no longer in use or outdated. I tried upgrading to the latest version of Node they had available, but I got the same generic error. Interestingly, I was able to get it setup on my computer in about 20 minutes. The only problem I ran into was needing to reinstall some of the packages.

mmarron79 commented 11 months ago

We got the packages installed. Apparently the issue now is the port number referenced in index.js. Since my app url doesn't require a port number, I assume this should be 80, but that didn't work (I get a 404 error).

mmarron79 commented 11 months ago

My hosting company was never able to figure out the problem, so I've given up on hosting the app. Fortunately, I figure out that I can technically run it using the files in the dist folder. Now my problem is figuring out how to refresh that folder when I make changes to the app code. Is there a command I can run to make that happen?

netbymatt commented 10 months ago

Instead of grabbing the zip file and unpacking it on your server, use git to get a copy of it and then later manage the updates.

Once git is installed on your server start with git clone https://github.com/netbymatt/ws4kp.git Which will get a copy of this code and put it in the /ws4kp subdirectory from where you run this command.

Then when you want to update use git pull to update files to the latest version.

mmarron79 commented 10 months ago

Thanks for the reply, but I don't want to update it based on changes you make. I want to update the files in the dist folder based on changes I make locally. Maybe the question I need to ask is how do the files in dist (like index.html and ws.min.js) get created or updated?

netbymatt commented 10 months ago

Gulp is used to build the distribution files. Looking at how I've arranged the tasks I have an imperfect solution for now, and I can make it a little less messy in the future.

Currently I have a task called publish-frontend. It builds all the html, js and css files and puts them in dist. Then it goes on to publish them to an s3 bucket where I host this from. You can still run the task, and the dist folder will be updated. You'll just get a lot of errors because it won't be able to do the publish.

Here's the command to run:

npx gulp publish-frontend
netbymatt commented 10 months ago

81561f75a1e00b0bcbf658b313e049ba11d7ebab added a new gulp task that only builds the dist folder. This is the error free way to accomplish what you're asking.

npx gulp build-dist
mmarron79 commented 10 months ago

Thanks! When I run either command, I get the following error:

Cannot find module: './lib/reorder'

mmarron79 commented 9 months ago

I figured it out! I needed to reinstall another batch of modules.