Merge pull request #3561 from dokku/3544-ps-can-scale

feat: disable scaling if app contains DOKKU_SCALE file
This commit is contained in:
Jose Diaz-Gonzalez
2019-05-19 22:59:08 -07:00
committed by GitHub
13 changed files with 127 additions and 6 deletions

View File

@@ -0,0 +1,5 @@
WAIT=2 # wait 2 seconds
TIMEOUT=5 # set timeout to 5 seconds
ATTEMPTS=2 # try 2 times
/ nodejs/express

View File

@@ -0,0 +1 @@
web=1

View File

@@ -0,0 +1,11 @@
FROM node:4
EXPOSE 3001/udp
EXPOSE 3000/tcp
EXPOSE 3003
COPY . /app
WORKDIR /app
RUN npm install
CMD npm start

View File

@@ -0,0 +1,8 @@
###############################
# DEVELOPMENT #
###############################
# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
cron: node worker.js
web: node web.js
worker: node worker.js

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
output="$(curl -s -S "$1")"
echo "$output"
test "$output" == "nodejs/express"

View File

@@ -0,0 +1,13 @@
{
"name": "node-example",
"version": "0.0.1",
"dependencies": {
"express": "2.5.x"
},
"engines": {
"node": "4.2.x"
},
"scripts": {
"start": "false"
}
}

View File

@@ -0,0 +1,12 @@
var express = require('express');
var app = express.createServer(express.logger());
app.get('/', function(request, response) {
response.send('nodejs/express');
});
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});

View File

@@ -0,0 +1,6 @@
function worker() {
console.log('sleeping for 60 seconds');
setTimeout(worker, 60 * 1000);
}
worker();

View File

@@ -134,6 +134,35 @@ teardown() {
assert_success
}
@test "(ps:scale) dockerfile dokku-scale" {
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
echo "output: $output"
echo "status: $status"
assert_success
deploy_app dockerfile-dokku-scale
CIDS=""
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
CIDS+=$(< $CID_FILE)
CIDS+=" "
done
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku ps:scale $TEST_APP web=1"
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku ps:report $TEST_APP --ps-can-scale"
echo "output: $output"
echo "status: $status"
assert_output "false"
}
@test "(ps) dockerfile with procfile" {
deploy_app dockerfile-procfile
run /bin/bash -c "dokku ps:stop $TEST_APP"