OLD | NEW |
1 Design | 1 Design |
2 ====== | 2 ====== |
3 | 3 |
4 | 4 |
5 Overview | 5 Overview |
6 -------- | 6 -------- |
7 Allows trying out Skia code in the browser. | 7 Allows trying out Skia code in the browser. |
8 | 8 |
9 | 9 |
10 Security | 10 Security |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 To connect to the database from the skia-webtry-b server: | 127 To connect to the database from the skia-webtry-b server: |
128 | 128 |
129 $ mysql --host=173.194.83.52 --user=root --password | 129 $ mysql --host=173.194.83.52 --user=root --password |
130 | 130 |
131 Initial setup of the database, the user, and the only table: | 131 Initial setup of the database, the user, and the only table: |
132 | 132 |
133 CREATE DATABASE webtry; | 133 CREATE DATABASE webtry; |
134 USE webtry; | 134 USE webtry; |
135 CREATE USER 'webtry'@'%' IDENTIFIED BY '<password is in valentine>'; | 135 CREATE USER 'webtry'@'%' IDENTIFIED BY '<password is in valentine>'; |
136 GRANT SELECT, INSERT, UPDATE ON webtry.webtry TO 'webtry'@'%'; | 136 GRANT SELECT, INSERT, UPDATE ON webtry.webtry TO 'webtry'@'%'; |
137 GRANT SELECT, INSERT, UPDATE ON webtry.workspace TO 'webtry'@'%'; | 137 GRANT SELECT, INSERT, UPDATE ON webtry.workspace TO 'webtry'@'%'; |
138 GRANT SELECT, INSERT, UPDATE ON webtry.workspacetry TO 'webtry'@'%'; | 138 GRANT SELECT, INSERT, UPDATE ON webtry.workspacetry TO 'webtry'@'%'; |
| 139 GRANT SELECT, INSERT, UPDATE ON webtry.source_images TO 'webtry'@'%'; |
139 | 140 |
140 // If this gets changed also update the sqlite create statement in webtry.go
. | 141 // If this gets changed also update the sqlite create statement in webtry.go
. |
141 | 142 |
142 CREATE TABLE webtry ( | 143 CREATE TABLE webtry ( |
143 code TEXT DEFAULT '' NOT NULL, | 144 code TEXT DEFAULT '' NOT NULL, |
144 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | 145 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
145 hash CHAR(64) DEFAULT '' NOT NULL, | 146 hash CHAR(64) DEFAULT '' NOT NULL, |
146 PRIMARY KEY(hash) | 147 source_image_id INTEGER DEFAULT 0 NOT NULL, |
| 148 PRIMARY KEY(hash), |
| 149 |
| 150 FOREIGN KEY (source) REFERENCES sources(id) |
147 ); | 151 ); |
148 | 152 |
149 CREATE TABLE workspace ( | 153 CREATE TABLE workspace ( |
150 name CHAR(64) DEFAULT '' NOT NULL, | 154 name CHAR(64) DEFAULT '' NOT NULL, |
151 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | 155 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
152 PRIMARY KEY(name) | 156 PRIMARY KEY(name), |
153 ); | 157 ); |
154 | 158 |
155 CREATE TABLE workspacetry ( | 159 CREATE TABLE workspacetry ( |
156 name CHAR(64) DEFAULT '' NOT NULL, | 160 name CHAR(64) DEFAULT '' NOT NULL, |
157 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | 161 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
158 hash CHAR(64) DEFAULT '' NOT NULL, | 162 hash CHAR(64) DEFAULT '' NOT NULL, |
159 hidden INTEGER DEFAULT 0 NOT NULL, | 163 source_image_id INTEGER DEFAULT 0 NOT NULL, |
| 164 hidden INTEGER DEFAULT 0 NOT NULL, |
160 | 165 |
161 FOREIGN KEY (name) REFERENCES workspace(name) | 166 FOREIGN KEY (name) REFERENCES workspace(name), |
162 ); | 167 ); |
163 | 168 |
| 169 CREATE TABLE source_images ( |
| 170 id INTEGER PRIMARY KEY NOT NULL, |
| 171 image MEDIUMBLOB DEFAULT '' NOT NULL, -- Stored as PN
G. |
| 172 width INTEGER DEFAULT 0 NOT NULL, |
| 173 height INTEGER DEFAULT 0 NOT NULL, |
| 174 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 175 hidden INTEGER DEFAULT 0 NOT NULL |
| 176 ); |
| 177 |
| 178 ALTER TABLE webtry ADD COLUMN source_image_id INTEGER DEFAULT 0 NOT NU
LL AFTER hash; |
| 179 ALTER TABLE workspacetry ADD COLUMN source_image_id INTEGER DEFAULT 0 NOT NU
LL AFTER hash; |
| 180 |
164 Common queries webtry.go will use: | 181 Common queries webtry.go will use: |
165 | 182 |
166 INSERT INTO webtry (code, hash) VALUES('int i = 0;...', 'abcdef...'); | 183 INSERT INTO webtry (code, hash) VALUES('int i = 0;...', 'abcdef...'); |
167 | 184 |
168 SELECT code, create_ts, hash FROM webtry WHERE hash='abcdef...'; | 185 SELECT code, create_ts, hash FROM webtry WHERE hash='abcdef...'; |
169 | 186 |
170 SELECT code, create_ts, hash FROM webtry ORDER BY create_ts DESC LIMIT 2; | 187 SELECT code, create_ts, hash FROM webtry ORDER BY create_ts DESC LIMIT 2; |
171 | 188 |
172 // To change the password for the webtry sql client: | 189 // To change the password for the webtry sql client: |
173 SET PASSWORD for 'webtry'@'%' = PASSWORD('<password is in valentine>'); | 190 SET PASSWORD for 'webtry'@'%' = PASSWORD('<password is in valentine>'); |
174 | 191 |
175 // Run before and after to confirm the password changed: | 192 // Run before and after to confirm the password changed: |
176 SELECT Host, User, Password FROM mysql.user; | 193 SELECT Host, User, Password FROM mysql.user; |
177 | 194 |
178 Common queries for workspaces: | 195 Common queries for workspaces: |
179 | 196 |
180 SELECT hash, create_ts FROM workspace ORDER BY create_ts DESC; | 197 SELECT hash, create_ts FROM workspace ORDER BY create_ts DESC; |
181 | 198 |
182 INSERT INTO workspace (name, hash) VALUES('autumn-river-12354', 'abcdef...')
; | 199 INSERT INTO workspace (name, hash) VALUES('autumn-river-12354', 'abcdef...')
; |
183 | 200 |
184 SELECT name FROM workspace GROUP BY name; | 201 SELECT name FROM workspace GROUP BY name; |
185 | 202 |
| 203 Common queries for sources: |
| 204 |
| 205 SELECT id, image, width, height, create_ts FROM source_images ORDER BY creat
e_ts DESC LIMIT 100; |
| 206 |
186 Password for the database will be stored in the metadata instance, if the | 207 Password for the database will be stored in the metadata instance, if the |
187 metadata server can't be found, i.e. running locally, then a local sqlite | 208 metadata server can't be found, i.e. running locally, then a local sqlite |
188 database will be used. To see the current password stored in metadata and the | 209 database will be used. To see the current password stored in metadata and the |
189 fingerprint: | 210 fingerprint: |
190 | 211 |
191 gcutil --project=google.com:skia-buildbots getinstance skia-webtry-b | 212 gcutil --project=google.com:skia-buildbots getinstance skia-webtry-b |
192 | 213 |
193 To set the mysql password that webtry is to use: | 214 To set the mysql password that webtry is to use: |
194 | 215 |
195 gcutil --project=google.com:skia-buildbots setinstancemetadata skia-webtr
y-b --metadata=password:'[mysql client webtry password]' --fingerprint=[some fin
gerprint] | 216 gcutil --project=google.com:skia-buildbots setinstancemetadata skia-webtr
y-b --metadata=password:'[mysql client webtry password]' --fingerprint=[some fin
gerprint] |
196 | 217 |
197 To retrieve the password from the running instance just GET the right URL from | 218 To retrieve the password from the running instance just GET the right URL from |
198 the metadata server: | 219 the metadata server: |
199 | 220 |
200 curl "http://metadata/computeMetadata/v1/instance/attributes/password" -H "X
-Google-Metadata-Request: True" | 221 curl "http://metadata/computeMetadata/v1/instance/attributes/password" -H "X
-Google-Metadata-Request: True" |
201 | 222 |
202 N.B. If you need to change the MySQL password that webtry uses, you must change | 223 N.B. If you need to change the MySQL password that webtry uses, you must change |
203 it both in MySQL and the value stored in the metadata server. | 224 it both in MySQL and the value stored in the metadata server. |
204 | 225 |
| 226 Source Images |
| 227 ------------- |
| 228 |
| 229 For every try the user can select an optional source image to use as an input. |
| 230 The id of the source image is just an integer and is stored in the database |
| 231 along with the other try information, such as the code. |
| 232 |
| 233 The actual image itself is also stored in a separate table, 'sources', in the |
| 234 database. On startup we check that all the images are available in 'inout', |
| 235 and write out the images if not. Since they are all written to 'inout' we can |
| 236 use the same /i/ image handler to serve them. |
| 237 |
| 238 When a user uploads an image it is decoded and converted to PNG and stored |
| 239 as a binary blob in the database. |
| 240 |
| 241 The bitmap is available to user code as a module level variable: |
| 242 |
| 243 SkBitmap source; |
| 244 |
| 245 The bitmap is read, decoded and stored in source before the seccomp jail is |
| 246 instantiated. |
| 247 |
| 248 |
205 Squid | 249 Squid |
206 ----- | 250 ----- |
207 | 251 |
208 Squid is configured to run on port 80 and run as an accelerator for the actual | 252 Squid is configured to run on port 80 and run as an accelerator for the actual |
209 Go program which is running on port 8000. The config for the squid proxy is | 253 Go program which is running on port 8000. The config for the squid proxy is |
210 held in sys/webtry_squid, which is copied into place during installation and | 254 held in sys/webtry_squid, which is copied into place during installation and |
211 squid is kept running via monit. | 255 squid is kept running via monit. |
212 | 256 |
213 Workspaces | 257 Workspaces |
214 ---------- | 258 ---------- |
(...skipping 14 matching lines...) Expand all Loading... |
229 * clike.js - C-like syntax highlighting support | 273 * clike.js - C-like syntax highlighting support |
230 | 274 |
231 Alternatively, we may consider pulling CM as an external dependency at some | 275 Alternatively, we may consider pulling CM as an external dependency at some |
232 point. | 276 point. |
233 | 277 |
234 Installation | 278 Installation |
235 ------------ | 279 ------------ |
236 See the README file. | 280 See the README file. |
237 | 281 |
238 | 282 |
OLD | NEW |