- "pm2" : The name of the cool Node Management platform that "on-the-fly" devotes resources to the given apps.
- "start" : Creates a new application
- "server/app.js" : The location of the main application .js
- "-u app-www" : The user to run under. We don't want PM2 to run as ROOT for security purposes, especially on port 80 or 443.
- "--watch" : Vital and saves each deployment from having to restart the application on each deployment. This is newly in place and still being tested. I originally thought it best to send a command after deployment was complete (and still do) but this may be just as good, and baked into the functionality of PM2.
- "--name app" : Force the name of the application (there could be many, but not in this current case). It's possible to run multiple applications under the same PM2 umbrella.
- "--" : Tells PM2 that everything after is a parameter to be sent to the Node Application
- Everything else, see below.
PM2 - Setup
Recent changes to the project now have it completely running under Node/Express/PM2. Details of the change(s) should be posted on the project's WIKI, but I thought it important enough to share what I've learned. This link was very helpful to get started.
When adding the application to PM2, the following line is used to register/start the application: (THIS ONLY NEEDS TO BE RUN ONCE. There is an entry in /etc/init.d that will run the PM2 Daemon on server startup)
pm2 start server/app.js –u app-www --watch --name app -- --app http://###################
Let's break it down (now):
Real World NodeJS w/ Continuous Integration
Running a NodeJS / Express / PM2
PM2 basically deamonizes node express... and when new files are uploaded need to run "pm2 restart"
A TeamCity plugin to ssh and run the above command is a must, and I can't seem to find one that exists.
I wrote a simple PowerShell script to execute PLink (from Putty) but will fail if the host thumbprint isnt already in the list of cached entries. Plink does provide means to enter the location of the private key file, but another/better solution ahould be used.
Follow-up: The TeamCity plug-in "Deployment" or "Deployer" contains this SSH Exec build runner... and a few others on the team are using it in their own projects. It really is a time/life saver.
Simple/Easy JS Click image switcher
This is pretty raw b/c out-of-the-box, Blogger doesn't support code blocks... but this is better than the empty page that existed.
onImg and offImg represent the on/off versions
onClick is a ternary expression that looks as the src filename, and replaces its value with the not-selected filename.
Pretty simple actually, but shows off the power of a simple ternary expression in JavaScript.
<script>
var onImg= "on.jpg";
var offImg= "off.jpg";
</script>
<img src="on.jpg" onclick="this.src = this.src == offImg ? onImg : offImg;"/>
Pretty simple actually, but shows off the power of a simple ternary expression in JavaScript.
Subscribe to:
Posts (Atom)
The Elder Scrolls: Oblivion - 2023 Experience
This article is a WIP. Setting up Oblivion in 2023 on a Steam Deck (w/ SteamOS) Install from Steam Vortex Experience (post base mod tools...
-
I recently had to install Ubuntu Desktop on a laptop that had a problematic NVidia chipset: The system would always freeze in a very short ...
-
[Part 1] [Part 2] [Part 3] Distractions Home distractions are very different than office workplace distractions because they are much mo...
-
[Part 1] [Part 2] [Part 3] I usually refrain from mentioning current and previous positions I've held and will continue to do so. This...