Skip to content

Custom restart policy #1342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cd ..
npm run docs
```

The webiste will now be running at [http://localhost:8080/](http://localhost:8080/).
The website will now be running at [http://localhost:8080/](http://localhost:8080/).

## Financial contributions

Expand Down
22 changes: 20 additions & 2 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ module.exports = {
// (runs docker network connect <net name> for each network listed here)
networks: [
'net1'
]
],

// Change the container's restart policy
// See https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policy
restartPolicy: 'always'
},

// list of servers to deploy to, from the 'servers' list
Expand Down Expand Up @@ -390,7 +394,7 @@ Meteor Up uses Docker to run and manage your app. It uses [MeteorD](https://gith

* Your currently running meteor bundle lives at `/opt/<appName>/current`
* We have a demonized docker container running the above bundle
* The docker container is started with `--restart=always` flag and it'll re-spawn the container if it dies
* The docker container is started with `--restart=always` flag (by default) and it'll re-spawn the container if it dies
* Logs are maintained via Docker
* If you decided to use MongoDB, it will be running as its own Docker container. It's bound to the local interface and to port `27017` (you cannot access it from the outside)
* The database is named `<appName>`
Expand Down Expand Up @@ -560,6 +564,20 @@ And then add a docker setup hook to login to your private registry on the server

You can set `app.docker.imagePort` to the port to expose from the container. This does not affect the port the app is accessed on, only the port the app runs on inside the docker container. It defaults to 3000.

### Restart policy

You can change the default ('always') [Docker restart policy](https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policy) by specifying `restartPolicy` in the 'docker' section of the config:

```
app: {
...
docker: {
...
restartPolicy: 'no'
}
}
```

## Reverse Proxy

Meteor Up can create a nginx reverse proxy that will handle SSL, and, if you are running multiple apps on the server, it will route requests to the correct app. The proxy is shared between all apps on the servers.
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/meteor/assets/templates/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fi

sudo docker run \
-d \
--restart=always \
--restart=<%= docker.restartPolicy %> \
$VOLUME \
<% if((sslConfig && typeof sslConfig.autogenerate === "object") || (typeof proxyConfig === "object" && !proxyConfig.loadBalancing)) { %> \
--expose=<%= docker.imagePort %> \
Expand Down Expand Up @@ -157,7 +157,7 @@ EOT
set -e
sudo docker run \
-d \
--restart=always \
--restart=<%= docker.restartPolicy %> \
--volume=/opt/$APPNAME/config/bundle.crt:/bundle.crt \
--volume=/opt/$APPNAME/config/private.key:/private.key \
--link=$APPNAME:backend \
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/meteor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export function prepareConfig(config, api) {
config.app.buildOptions.cleanBuildLocation = true;
}

config.app.docker.restartPolicy = config.app.docker.restartPolicy || 'always';

return config;
}

Expand Down