Commit Graph

233 Commits

Author SHA1 Message Date
Tim Abbott a4383f8264 Remove batch_bulk_create helper function.
The behavior we require is now standard in Django 1.5.

(imported from commit 509adb0bd371081a2dad7d4a04d24fcffbda7cdc)
2013-03-28 07:36:10 -04:00
Tim Abbott e2d010ef2d Fix most unnecessary database queries in huddle creation.
This saves 2 database queries per user in the huddle when sending the
first message to a particular huddle.

(imported from commit f71aa32df846fb4b82651a93ff9608087ffcaa5a)
2013-03-28 07:36:10 -04:00
Tim Abbott 36f09729e6 Run the memcached cache filling jobs in separate processes.
This will significantly improve the speed with which the memcached
caches are filled.

(imported from commit 445fec710a00b3d19b7962beddf89d4a75322eab)
2013-03-27 12:59:23 -04:00
Tim Abbott 144987e581 logs: Provide total time passed for longpolled requests.
Also improve display of times passed -- we now use display short times
in milliseconds for easier reading.

(imported from commit 08e1e7e6acbef48453080864946f7602a3395e7c)
2013-03-27 08:19:27 -04:00
Tim Abbott f3ad2d7a6b Centralize dispatch logic for which queue processor to use.
Previous we had around 4 copies of the logic for deciding whether we
should publish data via a SimpleQueueClient queue, a
TornadoQueueClient queue, or to directly handle the operation, which
resulted in their getting out of sync and buggy (see e.g. the previous
commit).

We need to add a lock around adding things to the queue to work around
a bug with pika's BlockingConnection.

I should note that the previous logic in some places had a bunch of
tests of the form "elif settings.TEST_SUITE" for doing the work that
would have been done by the queue processor directly; these should
have just been "else" clauses -- since we generally want that code to
run on development environments whether or not the test suite is
currently running.

(imported from commit 16bdbed4fff04b1bda6fde3b16bee7359917720b)
2013-03-27 08:19:27 -04:00
Tim Abbott fde2243dbc [django 1.5] Update read flags handling to use new Django 1.5 syntax.
(imported from commit af1e2608b6d6d3677bf6266980d8dc77739aa4ba)
2013-03-27 08:19:26 -04:00
Jessica McKellar 53ec385d0b create_user: ask for realm as part of user creation.
With open realms, you can't infer the realm from the e-mail address.

(imported from commit c05afa586f121a38673f9e62281cf26c8590570b)
2013-03-23 00:19:37 -04:00
Jessica McKellar f87ffd0703 create_user: fix missing spaces in options error message.
(imported from commit 25ea284b17dfb3160aca336e31203991f70994d8)
2013-03-23 00:19:37 -04:00
Jessica McKellar e5f1dad409 create_user: remove unused imports.
(imported from commit b2dd10f73fb0285c2c92ab56b1111cf9e859cedf)
2013-03-23 00:19:37 -04:00
Jessica McKellar ea11ce4ae6 create_user: Add Terms of Service warning.
(imported from commit bdb31aebad397e98db77d3ea95ef17ac9dd4737f)
2013-03-23 00:19:37 -04:00
Leo Franchi f64bc59dfb Automatically register consumer once asynchronous connection is completed
(imported from commit 3d860a9b79a42beffbd3b73f49aa2c25986dd3c6)
2013-03-22 15:55:49 -04:00
Leo Franchi c346abe6e2 Send Tornado callback notifications via RabbitMQ
(imported from commit 83814d8c6b78fe725aedea9d98fb588ed31123e7)
2013-03-22 15:55:40 -04:00
Keegan McAllister 23b8833ec5 Handle Tornado callback notify in a more generic, less HTTP-centric way
(imported from commit 85a74d1b40461236c4c95ad688e9796ab50f0bbf)
2013-03-22 15:51:23 -04:00
Keegan McAllister 591816d80e Use TornadoQueueClient in runtornado
(imported from commit cc4d5505987dc2826d177ff93d037b17f78072b8)
2013-03-22 15:39:07 -04:00
Leo Franchi 7837e36d0c Clean up some code by consolidating
(imported from commit 3978da70286174ad3666d08bcc8db2eb28446399)
2013-03-22 09:49:54 -04:00
Jessica McKellar 4f1bf1b2f2 realm_stats: restrict some usage stats to only active users.
They are more meaningful this way -- the fact that your bots that
never log in or inactive users don't have colored streams shouldn't
impact that statistic.

(imported from commit b39debda338cbbad06957bc969b42862a888026a)
2013-03-21 17:38:20 -04:00
Jessica McKellar 85086b6662 realm_stats: Also print enter-sends stats.
(imported from commit 34f9d9916e11ac2e2748ecbb8eb4f9a34a110340)
2013-03-21 17:38:20 -04:00
Leo Franchi 6d6c3364dc Rewrite message flag handling to fork out to a subprocess for batch handling
(imported from commit 1ef846f542950cabf32f8b176f5591cf5794a0ff)
2013-03-19 09:55:12 -04:00
Jessica McKellar 1ca2f6fa7f Add a management command to reset your stream colors to the default.
(imported from commit f6891ad40088bf34686a7d8a2d910a9a0f3be7c2)
2013-03-18 15:49:39 -04:00
Tim Abbott 722918aa61 Use humbug_finish() wrapper for finish() with required arguments.
I think this is a little cleaner than the previous approach.

(imported from commit fa6233721f43c94003de643d7801a88a156affd2)
2013-03-15 12:53:07 -04:00
Tim Abbott 419e153422 runtornado: Mark block of get_response modified from the original Django.
(imported from commit 383d6960f0043175c026956e1724ec1d1157767b)
2013-03-15 12:53:06 -04:00
Tim Abbott ade7146cd9 Disable tornado request logging in favor of our Django logging.
(imported from commit 2144b2ac1cdb6062bb32fca4cc69ea3f4570cf69)
2013-03-15 12:53:06 -04:00
Tim Abbott 4df6736225 Call the Django response middleware from Tornado views.
But discard any changes the Django response middleware may have made
to anything other than the content.

This allows us to, for example, output our nice database query logging
for get_updates requests.

(imported from commit e1d2fd38ceb4d73ff50bdfaad7c72ddb24d0fe16)
2013-03-15 12:53:06 -04:00
Tim Abbott 549577a928 Pass the original request object to Tornado's finish().
This is preparatory for running the Django response middleware on
our Tornado responses.

(imported from commit 05da8ea9cb663a928b2f98a928f3992aae4f067c)
2013-03-15 12:53:06 -04:00
Zev Benjamin 22457277f4 Move send_with_safety_check functionality into AsyncDjangoHandler
This will mainly be useful in the event system branch, where we want
to actually send a response from a file other than tornadoviews.py.

(imported from commit b7ae9bb9b062215ab44eb5f0a3a72d6baeee1d07)
2013-03-14 18:48:15 -04:00
Tim Abbott 76837ebe2c fill_memcached_caches: Also fill the caches of User/UserProfile objects.
Since we flush memcached when we do a server restart, the flurry of
get_updates requests that fly in afterwards are all cache misses for
getting the User/UserProfile objects, so Tornado ends up spending
around 70ms per get_updates request rather than the usual 1-2ms.

So this should substantially improve our Tornado performance around
server restarts.

(imported from commit 07b8126bdfd4ff14e4c3362f9eda1fe5fd571c5b)
2013-03-14 15:07:42 -04:00
Tim Abbott cf58ee833a Rename lib/message_cache.py to lib/cache_helpers.py
(imported from commit 591e427aee47aea58b50d6c3fbd6a05cfe9378ea)
2013-03-14 15:07:41 -04:00
Tim Abbott 60c3cf826d restart-server: Fill memcached caches after clearing the cache.
Our previous code could in theory end up clearing the caches it had
just filled, if Tornado's cache filling work happened to be faster
than the memcached flush.

(imported from commit 48174aadad398fb7a7c917a1df765c1261b12a55)
2013-03-14 15:07:41 -04:00
Leo Franchi 0f68411859 Mark messages as read when creating them in populate_db
(imported from commit 6bf0d5bf889e94618c355e56f145b353f7574e60)
2013-03-13 14:14:46 -04:00
Leo Franchi 153983a933 Add a manage.py command to add read flags up to the current pointer
This is required because our migration is going to go in two phases.
When we do the database migration (on pushing to master), we update
all messages at that point. But prod doesn't know about the new
flags field, so any new messages sent on prod will not have the
read bit set.

When we push to prod, we want to re-run the bit of the migration script
that automatically sets read flags on messages older than the users's
pointer.

(imported from commit 961d33e972eac9ada80089bf1b1269c7fb42d56b)
2013-03-13 14:14:45 -04:00
Leo Franchi 93a3f14c43 Add backend support for handling new 'read' message flag
(imported from commit 6194e9332caa2d279cbc304f0d6a69f969aa9a72)
2013-03-13 14:14:45 -04:00
Tim Abbott a22c5e63a8 create_user: Remove unused import.
(imported from commit 7a2a7c171b87d8098c0a589c1e6228c0b131eba1)
2013-03-08 17:24:33 -05:00
Jessica McKellar 2f644f8439 Add a management command to clean up lingering tutorial streams.
We now clean up the stream subscription in more places, but some
historical tutorial streams are still around and if an error or page
reload happens during the tutorial it'll stick around.

(imported from commit 8cf0ebda26bf752c1a23296a4ba85d194bbb3004)
2013-03-08 17:01:11 -05:00
Tim Abbott acab720502 Add support for making Tornado dump its stack via SIGUSR1/2.
With this change,

pkill -SIGUSR1 -f runtornado

will dump the stack and SIGUSR2 will enable an interactive debugging
session.

This fixes #613 for Tornado which was the original motive for that
ticket; I'm not sure whether we want to do this for our Django
processes as well, but it would be easy to do so if we did.

(imported from commit a7de7c6070f4bf0404bed6f434e6a6b291d66a26)
2013-03-06 14:19:32 -05:00
Jessica McKellar ac305ffc1d Add a management command to deactivate a user.
(imported from commit 14ef58bdd2cd20c05c68cd53cf911711d3bdb5fd)
2013-03-06 11:57:04 -05:00
Jessica McKellar 30c7bdf018 Fix bug in colorize_streams that tried to include non-streams for colorizing.
(imported from commit 286a6ab38513303968b3c476ebd528a3ab2cacf1)
2013-03-04 16:30:23 -05:00
Tim Abbott 1e9a85ff05 Fix use of case-sensitive comparisons on email addresses.
(imported from commit d420169640a9f9c034b3d9ded207e583691f6652)
2013-02-28 17:49:57 -05:00
Jessica McKellar a03a639cce Add a management script to set stream colors for a domain.
(imported from commit 186e8226b57d385bbbed756615c0c63315c9d463)
2013-02-28 16:41:44 -05:00
Luke Faraone 40ad84b363 Introduce script to bulk-create activation URIs.
(imported from commit 12435d8f0d48833f52a699c0d8a0c9ec0750e6af)
2013-02-28 14:34:18 -05:00
Waseem Daher 163c9c8d75 Add a JSON call that causes the tutorial bot to send you a message.
The idea here is: part of the onboarding tutorial is going to
be you talking to the tutorial bot and it talking to you, from
our Javascript.

The reason it's driven by Javascript is that then in principle we can
do nice stuff like making popovers appear in places to point things
out to you, whereas if we were to do it strictly server-side, doing so
would be a lot harder.

The downside to doing it in Javascript is that you don't get any of
the Markdown rendering, since that happens on the server. So instead
we add this call where you give it a message, and it responds by
having the tutorial bot send you that message.

I don't think there are any security concerns here because
(1) The bot only messages you -- so you can't use it to make someone
    else think that the system is telling them to do something
(2) If there were an issue associated with having the server parse
    arbitrary Markdown, you could just trigger the issue by sending
    a message yourself.

(imported from commit b34f594dab6be6bcb81899278ae1cbe447404468)
2013-02-20 23:04:49 +00:00
Leo Franchi 49328c2551 Unify rabbitmq usage to use only one queue.
To work around the issue we're having with queue draining between
parallel blocking connections, use the same rabbitmq queue for both
activity and presence events, keyed on a 'type' flag in the message
itself.

(imported from commit 188e8fda1695734e52c5740db2195072cfc81479)
2013-02-15 11:43:17 -05:00
Leo Franchi d4a582fa1c Handle SIGINT and SIGTERM in process_user_activity by closing communication gracefully
(imported from commit dcf813fa8af1aaf5d6cc635268757e40c6c202ab)
2013-02-15 11:05:31 -05:00
Jessica McKellar 7956f859b2 management: add a remove_users_from_stream command.
(imported from commit 4aeefcc5160a382b13f8bcc2321e76eeea55f4d3)
2013-02-12 11:49:22 -05:00
Jessica McKellar 645e7d58be management: fix add_users_to_streams given do_add_subscriptions output change.
(imported from commit bc03ee0bd601122689e2062b6963780743ac7d27)
2013-02-12 11:49:22 -05:00
Leo Franchi 0a0c4bb9a0 [manual] Use rabbitmq for asynchronous presence updating
Note: When deploying, restarting the process-user-activity-commandline script is needed

(imported from commit 63ee795c9c7a7db4a40170cff5636dc1dd0b46a8)
2013-02-11 18:05:57 -05:00
Jessica McKellar 53f0b00785 Add a management command to change and log user emails.
(imported from commit 0bf25433a371f7e46ade96019f4a9ceebe395fe5)
2013-02-10 16:45:25 -05:00
Keegan McAllister d349de903b queue: Get rid of lazy initialization in SimpleQueue
Instead make it a singleton with a get_instance() class method.

(imported from commit e32cabf77b43361e74a11a23bba3a6d9fb32f82f)
2013-02-08 13:57:22 -05:00
Keegan McAllister f14db52f22 queue: Rename SimpleQueue to SimpleQueueClient
It doesn't represent a single queue; that's what the 'queue_name' arguments are
for.

(imported from commit 8382ae6793ca7c3ae4b5aacf2c128113a7a88fb6)
2013-02-08 13:57:22 -05:00
Keegan McAllister 5be28bbbb4 expunge_logs: Abort on keyboard interrupt
(imported from commit b1fe93859c15e447c0935fcfb0e83a200bc016ba)
2013-02-07 11:34:49 -05:00
Jessica McKellar 4ac4e41b30 Add a realm_stats management command.
(imported from commit e23c9c521dff5e551615977ec5cd575bb5899ec6)
2013-02-02 08:24:21 -05:00