You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-16
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# sails-react-bootstrap-webpack
2
2
3
3
[](https://app.travis-ci.com/github/neonexus/sails-react-bootstrap-webpack)
If you would like to use [`sails-hook-autoreload`](https://npmjs.com/package/sails-hook-autoreload), just install it: `npm i sails-hook-autoreload --save-dev`. The config
538
538
file [`config/autoreload.js`](config/autoreload.js) is already pre-configured for this repo.
539
539
540
-
## Getting setup remotely
540
+
## Getting Setup Remotely
541
541
542
542
There are a lot of ways to go about remote deployments; many automated, some not so much. For the sake of argument, let's say you want to set up a remote server by hand. It would be nice if said
543
-
server (or servers if behind a load-balancer), could do a `git pull`, `npm install`, and an asset build if need be `npm run build`. It would also be great if you could see the progress, or even
543
+
server (or servers if behind a load-balancer), could do a `git pull`, `npm install`, and if need be `npm run build`. It would also be great if you could see the progress, or even
544
544
just the console of the Node server.
545
545
546
-
That's what the [`self-update.sh`](self-update.sh) and [`tmux.sh`](tmux.sh) shell scripts are for. Note, they are both defaulted to`bash`, but should work just fine in `zsh`.
546
+
That's what the [`self-update.sh`](self-update.sh) and [`tmux.sh`](tmux.sh) shell scripts are for. Note, they are both using`bash`, but should work just fine in `zsh`.
547
547
548
548
### What is TMUX?
549
549
550
550
In simplest terms, TMUX is a "terminal multiplexer". It lets you switch between programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.
551
551
552
-
In other words, it adds a lot of magic to the terminal. One of the most useful things, is being able to run programs in the background, but still being able to see the console output later (as
553
-
it is still running). It runs on most Linux-y distros, including macOS.
552
+
In other words, it adds a lot of magic to the terminal. One of the most useful things, is being able to run programs in the background, but still be able to see the console output later (as
553
+
it is still running). It runs (on the remote server) on most Linux-y distros, including macOS.
554
554
555
-
[Check out their "Getting Started" docs](https://github.com/tmux/tmux/wiki/Getting-Started) for more on what you can do.
555
+
[TMUXCheatSheet.com](https://tmuxcheatsheet.com/) has a great "how to install and use" that you can find here: https://tmuxcheatsheet.com/how-to-install-tmux/
556
+
557
+
Once installed, just run `tmux a` (or `tmux attach`), which will attach to the last open session. If there isn't one, it'll open one. Running just `tmux` will create a whole new session, and you
558
+
generally don't want that.
559
+
560
+
`Ctrl + b` is the command to start a TMUX shortcut. It is how you navigate around inside TMUX.
| Close Window |`Ctrl + b` then `&` (aka `Shift + 7`) OR just `exit`|
571
+
| Window Preview |`Ctrl + b` then `w`|
572
+
| Rename Window |`Ctrl + b` then `,`|
556
573
557
-
To install (remember: on the remote machine, not your local machine), it's most likely `sudo INSTALLER install tmux`. Amazon Linux is `sudo yum install tmux`, Ubuntu is `sudo apt-get install tmux`.
558
574
559
575
### A simple walkthrough for a self-updating VM
560
576
561
-
For this guide, I'm going to be using Amazon Linux as the basis; it's a great default if using AWS. However, most of these steps can easily be adapted.
577
+
For this guide, I'm going to be using Amazon Linux as the basis; it's a great default if using AWS. However, most of these steps can easily be adapted for other distros.
562
578
563
579
It should also be noted, this is by no means the only way to set up remote servers; nor is it a thorough guide. This is just a quick-n-dirty, get off the ground running without a lot of tooling, kind
564
580
of guide. There are PLENTY of automated deployment managers and documentation out there. This is fairly open-ended; it is assumed you know how to do a portion of basic remote server management.
@@ -636,7 +652,7 @@ Now that you have the server's public key saved in your repo, you should be able
Now, you'll want to `cd myapp`, and `npm install`.
642
658
@@ -645,13 +661,13 @@ the [environment variables](#environment-variables), but it is also possible to
645
661
646
662
#### Give it a spin
647
663
648
-
You should now be able to `sudo npm run lift:prod` (recommended for all remote environments, even DEV). `sudo` is needed on Amazon Linux, because it required ROOT permissions to open ports.
664
+
You should now be able to `sudo npm run lift:prod` (recommended for all remote environments, even DEV). `sudo` is needed on Amazon Linux, because it requires ROOT permissions to open ports.
649
665
650
666
If everything is working as intended... congrats (or so you thought)! Now that you have everything working; it's time to get the server to update / rebuild / start itself.
651
667
652
668
#### Final stretch
653
669
654
-
Now you need to decide how you are going to have the `tmux.sh` script run on startup. The easiest way would be to just install `cronie`:
670
+
Now you need to decide how you are going to have the `tmux.sh` script run on startup. The easiest way would be to just install `cronie` (for the use of `crontab`):
655
671
656
672
```shell
657
673
sudo yum install cronie
@@ -675,15 +691,20 @@ Now edit the `crontab` to run the script at `@reboot`:
675
691
676
692
#### Have you tried turning it off and on again?
677
693
694
+
Now force it to restart, and the instance should automatically lift the server.
695
+
678
696
```shell
679
697
sudo reboot
680
698
```
681
699
682
700
Now re-login to the instance. You should be able to `tmux attach` and see the Sails console.
683
701
702
+
Once you've verified everything works, you can use `./tmux.sh myapp status` / `./tmux.sh myapp start` / `./tmux.sh myapp stop` / `./tmux.sh myapp restart` (but you don't have to).
703
+
684
704
#### Now save that image!
685
705
686
-
Now you should create an AMI from that server. You should be able to terminate the running instance, and spin up a new one using your new custom AMI, and everything should just work.
706
+
Now that you have a self-starting/updating server, you should create an AMI from that instance. After it's been created, you should be able to terminate the running instance, and spin up a new one
707
+
using your new custom AMI, and everything should just work. Now you have the start of a robust remote fleet; because spinning up new servers is just a couple clicks (or commands) away.
0 commit comments