binarygiant
binarygiant

Reputation: 6422

Fleet NodeJS Deployment Tutorial

I am attempting to deploy a few NodeJS apps with Fleet: https://github.com/substack/fleet. I have read the blog post cited several times and have gotten a partially successful setup going.

I can on the server:

Create a fleet hub --> fleet hub --port=7000 --secret=beebop Create a fleet drone --> fleet drone --hub=localhost:7000 --secret=beebop

I can on my development machine:

Add the default fleet repo --> fleet remote add default --hub=172.16.10.147:7000 --secret=beebop

Then on the server again I can Spawn a node process --> fleet spawn -- app.js 3000 with the following output:

drone#ubuntu
└─┬ pid#bba906
  ├── status:   respawning
  ├── commit:   keystone-web/4eab770ded77b25a949795d0aed5727dd2783c4f
  └── command:  node app.js

I see the deployed app in the directory where I started the Fleet hub:

drwxr-xr-x 4 root root 4096 Mar 12 10:49 .
drwxr-xr-x 4 root root 4096 Mar 12 10:10 ..
drwxr-xr-x 8 root root 4096 Mar 12 10:49 myapp.4eab770ded77b25a949795d0aed5727dd2783c4f
drwxr-xr-x 9 root root 4096 Mar 12 10:27 myapp.eb350403b214f1023aff8405552ca27454673463
user@ubuntu:/opt/nodeapps/test/deploy$

My question is should I be able to now access the web app, e.g. localhost//:3000?

When I try to do so, the web browser reports that nothing is at the address.

Are there any tutorials beside the blog post for Fleet? I feel like I'm missing a step.

Thanks in advance,

Upvotes: 0

Views: 1219

Answers (1)

binarygiant
binarygiant

Reputation: 6422

See the script for the details. This is what I did, and it works pretty well for my scenario:

#!/bin/bash
option1="development"
option2="test"
option3="demo"
chosen=""

echo please enter environment setting for fleet/node deployment 1: "'"development"'" 2: "'"test"'" 3: "'"demo"'"
read env

if [[ $env == 1 ]]
    then
        chosen=$option1
elif [[ $env == 2 ]]
    then
        chosen=$option2
elif [[ $env == 3 ]]
    then chosen=$option3
else
    echo "you didn't enter a valid environment setting"
            echo "your options are" "1:'"$option1"'" "or" "2:'"$option2"'"
            exit
fi

echo deploying to "'"$chosen"'"
sleep 1
echo starting fleet deploy
fleet deploy --remote=$chosen
echo running npm install
fleet exec --remote=$chosen npm install
echo spawning application
fleet spawn --remote=$chosen --env.NODE_ENV=$chosen node app.js
fleet ps --remote=$chosen

Upvotes: 1

Related Questions