Aleksis Brezas
ffedae683d
early stage app
2015-10-13 13:19:44 -03:00
Pagan Gazzard
2d8df956a6
Move the starting timeout to a config var.
2015-10-13 13:19:44 -03:00
Pagan Gazzard
2210b1be29
Only wait for success if we're restarting due to an update attempt.
...
If we're restarting for binds/mounts then we're already in a non-working state, and starting the new supervisor may have to wait for bootstrap to complete (which takes an indefinite amount of time to complete, meaning the timeout was killing the new container before it could bootstrap in some cases)
2015-10-13 13:19:44 -03:00
Pagan Gazzard
5efcde7922
Start the supervisor update check ASAP, it allows us to push (and automatically update to) new supervisor images that fix issues in earlier stages.
2015-10-13 13:19:44 -03:00
Pagan Gazzard
5bb552f065
Make mixpanelTrack nicely handle errors being passed in and use it for logging bootstrapping errors.
2015-10-13 13:19:44 -03:00
Pagan Gazzard
f43afd4a95
Retry the bootstrap process if it fails - this means that we remove a point of failure (the previous connectivity check barrier merely reduced the chance of hitting that failure point)
2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
7866d7a9f7
Use API endpoint var as heartbeat endpoint.
2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
77f5c776f5
Allow configuration of heartbeat endpoint via env var.
2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
8ce9c2448f
Spread is neater.
2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
aa4ff76581
Avoid ICMP on connectivity check.
2015-10-13 13:19:44 -03:00
Petros Angelatos
d054ca7023
Use host networking for user containers
2015-10-13 13:19:44 -03:00
Aleksis Brezas
ff12b4b736
comment explaining why we dont throw on supervisor update
2015-10-13 13:19:44 -03:00
Aleksis Brezas
5a9f5bebc6
increase supervisor update timeout to 1 minute
2015-10-13 13:19:44 -03:00
Aleksis Brezas
81fbbab362
remove unnecessary catch
2015-10-13 13:19:44 -03:00
Aleksis Brezas
e65a0b9c66
do not throw update errors
2015-10-13 13:19:43 -03:00
Pagan Gazzard
58cbb3808e
Log the stack trace as well when catching an unhandled error.
2015-10-13 13:18:12 -03:00
Pagan Gazzard
4f431d36ed
Fix binding a folder using the wrong id.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
2746d875f7
Fix "undefined is not a function" error due to not passing a callback to container.stop
2015-10-13 13:10:12 -03:00
Pagan Gazzard
4734f8e834
Remove duplicate require.
2015-10-13 13:10:12 -03:00
Eugene Mirotin
31a48c75f5
pass the error message in despawn as well
2015-10-13 13:10:12 -03:00
Eugene Mirotin
378913862f
pass the proper error message
2015-10-13 13:10:12 -03:00
Lorenzo Stoakes
3810a394c9
Up max comment length to 120 chars.
2015-10-13 13:10:12 -03:00
Lorenzo Stoakes
f39b51885d
Syntax cleanup pass.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
70eef70be2
Log an error if failing to stop a tty session
2015-10-13 13:10:12 -03:00
Pagan Gazzard
a9672bd5af
Make sure that the command socket exists and is a socket.
...
This handles the case of running an updated supervisor on an old image which doesn't support host commands - printing out a nice message and waiting rather than exiting silently.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
33441c74e7
Silence the setting up of the socket.
...
This was appearing whenever you started a new tty.js terminal - leaking stuff that shouldn't really be.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
c1b1aba985
Make sure to stop any spawned tty sessions on container stop.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
ad107b30ae
Enable destroying a tty.js tunnel.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
1b0e364322
Enable spawning a tty.js tunnel.
2015-10-13 13:10:12 -03:00
Aleksis Brezas
aab2a3b3d3
missing require
2015-10-13 13:10:12 -03:00
Aleksis Brezas
839b6ec7ca
get full container id from /proc/1/cgroup
2015-10-13 13:10:12 -03:00
Aleksis Brezas
69e2af5aa1
wait for an ok from next supervisor before exit
2015-10-13 13:10:11 -03:00
Praneeth Bodduluri
b790e4e304
Blink interval of 200ms was too slow to be seen - reverting to 400ms used in api.coffee
2015-10-13 13:10:11 -03:00
Petros Angelatos
a10f118ab9
Use the registry endpoint from config, not environment
2015-10-13 13:10:11 -03:00
Pagan Gazzard
3c5e856ef2
Mount a /data directory for containers, to allow persistent storage.
2015-10-13 13:10:11 -03:00
Pagan Gazzard
a9fe6f3414
Update the app info the moment we create the container, even if then starting the container fails.
...
This stops issues with constantly creating new containers for an image that fails to start.
2015-10-13 13:10:11 -03:00
Praneeth Bodduluri
e7216618ad
Make Blinkable LED configurable + Move blink to utils + Check connectivity before bootstrap + Blink LED on loss of connection
2015-10-13 13:10:11 -03:00
Pagan Gazzard
3975939181
Cleanup unneeded images after a successful update.
2015-10-13 13:10:11 -03:00
Pagan Gazzard
4cc3092b73
Remove /dev mount, privileged flag does it by default.
2015-10-13 13:10:11 -03:00
Pagan Gazzard
d07c6abe99
Store and make use of container ids.
...
This stores the container id for an app when creating that app, using it when it is necessary to stop/remove the app and when attempting to start it again (rather than creating a new container each time, eg restarting the pi does not create a new container any more)
2015-10-13 13:10:11 -03:00
Pagan Gazzard
51bfb69354
Treat the bluebird OperationalError wrapper correctly.
2015-10-13 13:10:11 -03:00
Pagan Gazzard
0fae904f1c
Make sure to use string comparisons for the status code, to avoid issues where the types are different.
2015-10-13 13:10:10 -03:00
Praneeth Bodduluri
7aa66b5cb6
x86 support + Change localImage variable to SUPERVISOR_IMAGE
2015-10-13 13:09:58 -03:00
Pagan Gazzard
e64e6e6dbe
Handle trying to remove already stopped/removed containers gracefully.
2015-10-13 13:08:24 -03:00
Pagan Gazzard
7072b1df96
On update failure schedule another attempt briefly in the future.
2015-10-13 13:08:24 -03:00
Praneeth Bodduluri
0f23ddded8
Change the data mount point to /resin-data
2015-10-13 13:08:23 -03:00
Petros Angelatos
d511d9df94
Set the 'RESIN' env var in user applications
2015-10-13 13:08:23 -03:00
Pagan Gazzard
5bd4ee7ee6
Fix event-stream usage.
2015-10-13 13:08:23 -03:00
Pagan Gazzard
f317927284
Move the restart check to the earliest possible stage, such that the only mount that we actually need in order to bootstrap the the docker.sock mounting.
2015-10-13 13:08:23 -03:00
Pagan Gazzard
2c11b34bdf
Have the supervisor update if it finds itself missing Volumes/Binds it expects to have (or has additional that it does not expect).
...
Conflicts:
src/config.coffee
src/supervisor-update.coffee
2015-10-13 13:08:23 -03:00
Pagan Gazzard
b7149bb266
Report the commit to the API as soon as the container is started.
2015-10-13 13:08:23 -03:00
Pagan Gazzard
3ef5a86344
Report the device status to the API
2015-10-13 13:08:23 -03:00
Pagan Gazzard
c436d8d5c0
Set default values for the config vars, which will be used in the case of an env var not being set, and copy all existing env vars in the case of an update.
2015-10-13 13:08:07 -03:00
Pagan Gazzard
c03a51d404
Make sure the fib_trie mount is propogated on an update.
2015-10-13 13:06:43 -03:00
Pagan Gazzard
a47022a0b4
Report the host ip address to the API on startup and every 5mins after.
2015-10-13 13:06:43 -03:00
Pagan Gazzard
6fb20a5dc5
Add support for exposing multiple ports.
2015-10-13 13:06:42 -03:00
Petros Angelatos
3ae3668221
Test for both 'id' and 'Id' when docker responds with image info
2015-10-13 13:06:42 -03:00
Pagan Gazzard
58035f8b24
Switch from "id" to "Id" to match a docker change..
2015-10-13 13:06:42 -03:00
Pagan Gazzard
597fefcb33
Fix reference error.
2015-10-13 13:06:42 -03:00
Pagan Gazzard
148d067ab9
Add a log entry that we're exiting on a supervisor update.
2015-10-13 13:06:42 -03:00
Petros Angelatos
3e1dd1f922
Log every mixpanel event and remove redundant logs
2015-10-13 13:06:42 -03:00
Petros Angelatos
d00372b5d2
Move mixpanel calls inside corresponding methods
2015-10-13 13:06:42 -03:00
Petros Angelatos
d06b5117f0
Keep method of loading JSON files consistent
2015-10-13 13:06:42 -03:00
Petros Angelatos
7b483e983d
Fix bug of using mixpanel module as the mixpanel client
2015-10-13 13:06:42 -03:00
Petros Angelatos
e622491f37
Add mixpanel events to the update process
2015-10-13 13:06:42 -03:00
Petros Angelatos
1501cf3122
Integrate mixpanel
2015-10-13 13:06:42 -03:00
Petros Angelatos
0772638d92
Supply USER environment variable to containers
2015-10-13 13:06:42 -03:00
Petros Angelatos
a5fa371f22
Bind mount /lib/modules to enable module loading from inside the container
2015-10-13 13:06:42 -03:00
Page
4cfcd39524
Enable periodic update checks, and add logic to only switch to the new image if it is different.
2015-10-13 13:06:42 -03:00
Page
0d2d372cb9
Share the docker socket via config.
2015-10-13 13:06:42 -03:00
Page
959da25c9f
Add all expected env vars to the new supervisor container.
2015-10-13 13:06:41 -03:00
Page
f78786b065
Rename the images more appropriately.
2015-10-13 13:06:41 -03:00
Page
599f8ae503
Remove trailing commas.
2015-10-13 13:06:41 -03:00
Page
96d1e48edd
Use a promise constructor so we can make the code a bit cleaner.
2015-10-13 13:06:41 -03:00
Page
a0f9219cb3
Initial version of self-updates, adds an "/v1/update-supervisor" endpoint that can be posted to in order to trigger a supervisor update, which it then fetches as the resin/rpi-supervisor repo of the registry endpoint.
2015-10-13 13:06:41 -03:00
Petros Angelatos
d47ba654b7
Pass the device uuid as an env var
2015-10-13 13:06:41 -03:00
Petros Angelatos
04ca3b3042
Clarify publish function definition
2015-10-13 13:06:41 -03:00
Petros Angelatos
7e5fe4802f
Don't filter out ANSI colours
2015-10-13 13:06:41 -03:00
Petros Angelatos
29f5c9b7e0
Use promise API
2015-10-13 13:06:41 -03:00
Petros Angelatos
604a05a21a
Style fixes
2015-10-13 13:06:41 -03:00
Petros Angelatos
94eeaaa510
Resolve variable collision
2015-10-13 13:06:41 -03:00
Petros Angelatos
39261f5d6b
Enclose publish queuing vars in their own closure
2015-10-13 13:06:41 -03:00
Petros Angelatos
7c33f28724
Queue publish calls while getting uuid from db
2015-10-13 13:06:41 -03:00
Petros Angelatos
ca736233e7
Move all configuration variables to a separate file
2015-10-13 13:06:39 -03:00
Petros Angelatos
5caace400f
Send logs through pubnub
2015-10-13 13:04:25 -03:00
Page
ff7d6c1f8a
Add missing paren.
2015-10-13 13:03:16 -03:00
Page
b3f9f9b1ef
Switch to using the Promise constructor rather than deferred, it allows for slightly nicer code. Also add some parens in appropriate places.
2015-10-13 13:03:16 -03:00
Page
4d5c18ec6f
Fetch the image using dockerode.
2015-10-13 13:03:16 -03:00
Page
7daebaf85e
Fix check if we already have the image.
2015-10-13 13:03:16 -03:00
Page
f47e7fbf2b
We have to manually stringify/parse the JSON column for knex - fixes containers restarting every 6 minutes.
2015-10-13 13:03:16 -03:00
Petros Angelatos
e9cbeea11e
Docker expects the port to be a string
2015-10-13 13:03:16 -03:00
Petros Angelatos
3c4318893a
Remove unused version
variable
2015-10-13 13:03:16 -03:00
Petros Angelatos
98870dcd16
Generate random UUID
...
Generate a random UUID when the device bootstraps instead of
deterministically calculating one from the CPU serial number. This means
that a specific device can be used with many applications and users
without problem.
2015-10-13 13:03:16 -03:00
Petros Angelatos
2b054123fe
Remove unused crypto module
2015-10-13 13:03:16 -03:00
Petros Angelatos
387ac995a4
Remove unmatched )
2015-10-13 13:03:16 -03:00
Page
ab642470ec
Make sure the PORT env var is a valid port number before trying to bind it.
2015-10-13 13:03:16 -03:00
Page
9ca8077daa
Use the PORT environment variable to choose what port to expose.
...
Conflicts:
src/application.coffee
2015-10-13 13:03:16 -03:00
Page
99849ad84c
Publish tcp ports 80 and 443 of the container.
...
Conflicts:
src/application.coffee
Conflicts:
src/application.coffee
2015-10-13 13:03:16 -03:00
Page
38481f524d
Make sure all apps are removed before adding new/updating existing, this is to make sure any ports they use have been freed in case they're needed by the new/updated apps.
...
Conflicts:
src/application.coffee
2015-10-13 13:03:15 -03:00
Page
97d2771826
Change automatic update check to every 5 mins instead of 15.
2015-10-13 13:03:15 -03:00
Vasilis Souleles
502fa105b1
removed unnecessary changes part 2
2015-10-13 13:03:15 -03:00
Vasilis Souleles
34cbb1e699
removed unnecessary changes
2015-10-13 13:03:15 -03:00
Vasilis Souleles
e0aa5e3929
fixed dumb bug
2015-10-13 13:03:15 -03:00
Vasilis Souleles
9a87a8fbf5
fixed tabs over spaces
2015-10-13 13:03:15 -03:00
Vasilis Souleles
1c3e173bd3
added resin-supervisor version as a field of config object. added some notes on posting version using resinAPI
2015-10-13 13:03:15 -03:00
Page
5e620cbf03
Fix typo.
2015-10-13 13:03:15 -03:00
Page
5d89b74bab
Use __dirname to make sure the relative path is relative to where we expect.
2015-10-13 13:03:15 -03:00
Page
791cbda490
Fix typo.
2015-10-13 13:03:15 -03:00
Page
06ef69f87e
Only allow one update to be occurring at a time, and if another is triggered whilst one is in progress then simply schedule it for after the current one finishes.
2015-10-13 13:03:15 -03:00
Page
9c9288e179
Move the REGISTRY_ENDPOINT into an env var.
2015-10-13 13:03:15 -03:00
Page
b4756db23b
The apps to update are the ones that aren't equal!
2015-10-13 13:03:15 -03:00
Page
1b74e0cca5
Pass the env vars in the way docker expects.
2015-10-13 13:03:15 -03:00
Vasilis Souleles
a51a648267
read utf-8 data. fixed Promises bug
2015-10-13 13:03:15 -03:00
Vasilis Souleles
10451fd27d
added getSupevisorVersion
2015-10-13 13:03:15 -03:00
Page
b435116207
env is a property, not a var of its own.
2015-10-13 13:03:15 -03:00
Petros Angelatos
1b0a27f19d
Remove assumption of supervisor path
2015-10-13 13:01:25 -03:00
Petros Angelatos
c7ce76c436
Use /data instead of /supervisor/data
2015-10-13 13:01:25 -03:00
Petros Angelatos
1654e26245
Drop legacy parameter used in Procfiles
2015-10-13 13:01:25 -03:00
Page
16fb88fab0
We can now use coffee-script for the main file, since it will be compiled before being run anyway.
2015-10-13 13:01:25 -03:00
Page
1c209fa827
Compile all the coffee-script files once after installing, rather than on each run.
2015-10-13 13:01:25 -03:00
Page
7e25bfe91a
Expose the docker socket of master that we would need to launch a new resin-supervisor container.
2015-10-13 13:01:25 -03:00
Page
e336eaad6e
Increase the blink duration to 15s
2015-10-13 13:01:25 -03:00
Page
b47e8a18dd
Get the app object from the local apps - that's the only place it exists!
2015-10-13 13:01:24 -03:00
Page
5482b9208d
Properly stop and remove containers.
2015-10-13 12:58:58 -03:00
Page
238768e7d4
Add support for environment variables.
...
Conflicts:
src/application.coffee
Conflicts:
src/application.coffee
2015-10-13 12:58:58 -03:00
Page
4157ab036c
Extract out the docker socket and registry endpoint to constants, so they are easier to change/update.
2015-10-13 12:58:58 -03:00
Page
bc0d981610
Use an app object throughout, rather than relying upon just the imageId, this is very useful for adding extra properties to the app when starting/etc (eg env vars/ports/etc)
2015-10-13 12:58:58 -03:00
Page
4d4b633fde
Improve feedback for starting an app
2015-10-13 12:58:58 -03:00
Page
eaa16ccd31
Separate the url resolve onto a new line.
2015-10-13 12:58:58 -03:00
Page
a5aaee107d
Use the resin-platform-api to access the platform.
2015-10-13 12:58:57 -03:00
Page
c8d8ca9736
Use /run/docker.sock for docker, since it will work when run on a host (and can now be used in a container to access the host docker as well)
2015-10-13 12:58:57 -03:00
Page
c229e8fd49
If bootstrapping fails, then actually fail, rather than covering up the error (the error will still get logged by bluebird if the promise rejection isn't handled - but the returned promise will actually be rejected now)
2015-10-13 12:58:57 -03:00
Page
795b8b4299
And actually remove the now-unused delay function.
2015-10-13 12:58:57 -03:00
Page
2d6f0a7e6d
Update bluebird and use the delay helper.
2015-10-13 12:58:57 -03:00
Page
b65e3fd3f9
Remove some more unnecessary parens.
2015-10-13 12:58:57 -03:00
Page
e8e6490dd2
Update to coffee-script 1.7.1
2015-10-13 12:58:57 -03:00
Page
37212cedbe
Remove a load of unnecessary parens.
2015-10-13 12:58:57 -03:00
Page
3c3e81a892
Install apps in parallel to deleting them - also fixes SQL errors when there are no apps to install.
2015-10-13 12:58:57 -03:00
Petros Aggelatos
87534cb15e
Expose the whole /dev directory in the container
2015-10-13 12:58:57 -03:00
Petros Aggelatos
31a9632fe3
Bug fix. Needed to declade a volume to use bind mounts
2015-10-13 12:58:57 -03:00
Petros Aggelatos
0e360b56ac
Bind mount /dev/snd so that containers can play sound
2015-10-13 12:58:57 -03:00
Petros Aggelatos
c0bfbc582d
Print helpful message instead of caught error
2015-10-13 12:58:57 -03:00
Petros Aggelatos
3aed83fe04
Removed unsed variables
2015-10-13 12:58:57 -03:00
Petros Aggelatos
94395c7e12
Bugfix. .then() expects a function
2015-10-13 12:58:56 -03:00
Petros Aggelatos
117251bbc1
Only start an application when there is a commit
2015-10-13 12:58:56 -03:00
Petros Aggelatos
57e8b10928
Make all applications privileged
2015-10-13 12:58:56 -03:00
Petros Aggelatos
cec5347c6c
Print the application Id
2015-10-13 12:58:56 -03:00
Petros Aggelatos
637d68921f
Application management code in its own module
2015-10-13 12:58:56 -03:00
Petros Aggelatos
614b24c796
Fix output format of VPN logs
2015-10-13 12:58:56 -03:00
Petros Aggelatos
12b3e194b5
Run application when supervisor starts
2015-10-13 12:58:56 -03:00
Petros Aggelatos
563df5386d
On update get application info from the API
2015-10-13 12:58:56 -03:00
Petros Aggelatos
f10fb532c6
Use versioned API endpoints
2015-10-13 12:58:56 -03:00
Petros Aggelatos
91b59abd42
Save parameters in SQLite on successful bootstrapping
2015-10-13 12:58:56 -03:00
Petros Aggelatos
1dc26396a2
Elegant require calls
2015-10-13 12:58:56 -03:00
Petros Aggelatos
469777c232
Don't crash on uncaught exceptions
2015-10-13 12:58:56 -03:00
Petros Aggelatos
dc3708d14f
Wait for db initialisation before starting app
2015-10-13 12:58:56 -03:00
Petros Aggelatos
e5684a1c3a
Promisify blink
2015-10-13 12:58:56 -03:00
Petros Aggelatos
a8846b37b6
Minor log change
2015-10-13 12:58:56 -03:00
Petros Aggelatos
ef970712a8
Table config should have key
as primary key
2015-10-13 12:58:56 -03:00
Petros Aggelatos
c98a274bde
Fixed syntax errors
2015-10-13 12:58:55 -03:00
Petros Aggelatos
48c5766f3d
Cleanup unneeded files
2015-10-13 12:58:55 -03:00
Petros Aggelatos
309da94028
OCD
2015-10-13 12:58:55 -03:00
Petros Aggelatos
de342a9209
Revamp/rewrite of supervisor as a docker application
2015-10-13 12:58:55 -03:00