Sana installation on an Amazon Machine Image

299 views
Skip to first unread message

Eric Winkler

unread,
Dec 5, 2012, 4:42:32 PM12/5/12
to sana-...@googlegroups.com
This is a thread for discussions about installing onto an Amazon Machine Image. It assumes you have an account set up with Amazon and are familiar with the AWS management console and connecting to a running AMI over ssh. The micro instance id used for installing was ami-013f9768. Note: the micro instance seem to work fine for basic testing but are a bit underpowered for a production environment. 

64 bit Ubuntu 12.04 LTS micro instance Sana install.
In general, just follow the Sana Manual Installation instructions. There are however a couple of additional steps that should make the micro instance AMI run better.

1. Memory Issues. Basically it just requires creating a swap block on the file system. The following link provides instructions (Note: I used a 1 GB swap instead of the 512 MB described on the page

2. OpenMRS Report Scheduler. (Seems necessary for 1.9.1 but may have been corrected in other versions). The report scheduler used the default admin:test as credentials rather than what was entered during the installation. To correct just go to Administration --> Settings --> Scheduler and update the username and password as necessary (I created a user specifically for the task but I am not certain that is absolutely required). If not corrected, it will throw a large number of Exceptions and slow OpenMRS down considerably. Note this step is only necessary if you are using a newer version of OpenMRS and the Sana module built from the Sana git repo.

Eric 
Sana Development

Poppasmurf

unread,
Dec 8, 2012, 4:27:15 PM12/8/12
to sana-...@googlegroups.com
Thank you for the quick response. I have been hard at work settings this up using the manual install instructions. I have hit a few snags along the way and I was wondering if you could lend some insight.

The mds server following the test "navigate with a browser to: http://localhost/mds/"

..for me, it is navigating with a browser to: http://localhost:9000/mds/ , using the actual address :9000/mds nets me the following message:

"could not import sana.settings". The servername line (domU-12-31-39-07-1E-87.compute-1.internal) seems odd as that is neither my AWS image nor is there any mention of it in the settings files after a string search through the sana folder.


MOD_PYTHON ERROR

ProcessId:      26201
Interpreter:    'mds'

ServerName:     'domU-12-31-39-07-1E-87.compute-1.internal'
DocumentRoot:   '/etc/apache2/htdocs'

URI:            '/mds'
Location:       '/mds'
Directory:      None
Filename:       '/etc/apache2/htdocs'
PathInfo:       '/mds'

Phase:          'PythonHandler'
Handler:        'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 212, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 174, in __call__
    self.load_middleware()

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
    self._setup()

  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)

  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 89, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'sana.settings' (Is it on sys.path?): No module named sana.settings



My default site in apache has the following added section and ports.conf has a listen 9000 and the EC2 firewall is accepting traffic on 9000

<VirtualHost *:9000>

<Location "/mds">

SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonDebug On
SetEnv DJANGO_SETTINGS_MODULE sana.settings
PythonPath "['/home/unbuntu/sana'] + sys.path"
PythonInterpreter mds
PythonOption django.root /mds

</Location>
<Location "/mds/media">

SetHandler none

</Location>

</VirtualHost>



Any help would be greatly appreciated.

Also, for the openmrs setup, I added

Contact Phone java.lang.String Phone number for person for Moca notifications
Contact Email java.lang.String Email for person for Moca notifications

with no edit privileges but these do not show up under advanced when creating users. I am using openmrs 1.6.1. What further do I need to do in order for these fields to show up?

Eric Winkler

unread,
Dec 10, 2012, 5:14:11 PM12/10/12
to sana-...@googlegroups.com
Regarding your issues:

1. No module named sana.settings. Just to double check, did you create the settings.py file file from the template, settings.py.tmpl. (Reference: Configure MDS (Update settings file)). It basically looks like Apache isn't finding the settings file. Is the extra n in ubuntu for the PythonPath a typo: '/home/unbuntu/sana'? I believe the default home directory would be /home/ubuntu on the AMI's. Another common problem is that the link from <Document Root>/mds to the sana directory is missing. Hope that helps please reply if you continue to have issues.

2. User Attributes. Unfortunately, there is an issue that got dropped from the wiki instructions that relates to a bug in OpenMRS that causes the problem you are describing. For the moment, the workaround for getting the email to work is to have the user enter an email address in the My Profile --> Notifications page. For the sms service, the number should get pulled from the one included with the encounter POST and stored with the entry in the Queue. I will double check the instructions on the wiki and correct any discrepancies.

Best,
Eric W
Sana Development

Peter Lazar

unread,
Dec 11, 2012, 10:21:13 AM12/11/12
to sana-users on behalf of Eric Winkler
Alas, you caught a typo on my part. It was an extraneous "n" but it did not solve the problem. Thank you for being that extra set of eyes.

I did, in fact, create the settings.py from the .tmpl file and I set the ownership of the entire directory to www-data. I added a document-root entry in the apache default file to point to /home/ubuntu/sana for port 9000. Do I need some special considerations in the settings.py file to run under a different port?

What is this odd servername? "domu...etc"? Is this an AWS thing for catching errors? The real server name is "EC2...etc"

MOD_PYTHON ERROR

ProcessId:      31642
Interpreter:    'mds'

ServerName:     'domU-12-31-39-07-1E-87.compute-1.internal'
DocumentRoot:   '/home/ubuntu/sana'

URI:            '/mds'
Location:       '/mds'
Directory:      None
Filename:       '/home/ubuntu/sana/mds'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 212, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 174, in __call__
    self.load_middleware()

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
    self._setup()

  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)

  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 89, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'sana.settings' (Is it on sys.path?): No module named sana.settings


Eric Winkler

unread,
Dec 11, 2012, 4:07:42 PM12/11/12
to sana-...@googlegroups.com
Probably should have caught this after reading your first post but I believe the problem is with this line:

PythonPath "['/home/unbuntu/sana'] + sys.path"

That would result in the python interpreter look for the settings as /home/ubuntu/sana/sana/settings.py.

Regarding the different internal and external host names, I believe it is just how Amazon maps the vms on their internal network. I get a similar discrepancy between what shows up if I enter 'hostname -f' from an ssh shell vs the external host I use to connect to in a browser. It doesn't seem to cause any problems with the instance I am using.

Best,
Eric

Peter Lazar

unread,
Dec 11, 2012, 9:40:12 PM12/11/12
to sana-users on behalf of Eric Winkler
Glorious Victory! (Sort of ;) )

With your sage advice, I was able to get the entire stack running (MDS without SMS support for the moment), I installed the android emulator and had a go at it.

I added the client, set the MDS URI to   ec2...blah blah...com:9000/mrs , set the admin password, did a database refresh and filled out an oral cancer screening form with patient creation.

The saved procedures report upload failed but the patient is created.....with no encounters. Do I need to precreate a form to receive this data in order to generate an encounter and clear the items from the client?

Eric Winkler

unread,
Dec 12, 2012, 10:24:06 AM12/12/12
to sana-...@googlegroups.com
The client is coded to POST to the MDS URI + /mds-the /mds bit gets appended automatically. Basically, your client would be sending the requests to ec2...blah blah...com:9000/mrs/mds. Is that where you would want them sent?
Eric

Peter Lazar

unread,
Dec 12, 2012, 11:12:47 AM12/12/12
to sana-users on behalf of Eric Winkler
Yes (that was a typo...it is mDs) .

I set it to be ...etc.etc...com:9000

and it seems to create the patient but cannot finish uploading the record....it just says upload failed for any form I attempt to fill out using the SANA client. The patient record DOES get created, however. So some communication is happening but there is nothing in the moca queue and no actual forms. Am I missing a piece?

Eric Winkler

unread,
Dec 13, 2012, 4:59:39 AM12/13/12
to sana-...@googlegroups.com
Once the encounter is uploaded the patient gets created first, and in a separate POST, from mds. My suspicion is that it is a missing COncept issue which seems to cause the bulk of the upload failures I see. If you navigate to ...:9000/mds/log, you should get something that looks like:

12/13/2012 03:51:48/mds/json/procedure/submit/0.6358s
12/13/2012 03:51:43/mds/json/procedure/submit/0.7885s
12/13/2012 03:51:28/mds/json/procedure/submit/0.7767s
12/13/2012 03:51:24/mds/json/procedure/submit/0.8536s
12/13/2012 03:51:18/mds/json/procedure/submit/1.0558s

Click on one of the entries and it should expand and give you some debugging output from the upload attempt. In particular, the last line or two of the expansion should have something useful. The following example is off of our demo server:

ERROR json.py:230  Failed to register procedure: sp.pk -> 697, Concept error: Concept Undefined: (SEX, Select Client's Gender:)

If there is nothing useful, you can also try checking the tomcat logs in /var/log/tomcat6/catalina.out.

On Wednesday, December 12, 2012 11:12:47 AM UTC-5, Poppasmurf wrote:
Yes (that was a typo...it is mDs) .

I set it to be ...etc.etc...com:9000

and it seems to create the patient but cannot finish uploading the record....it just says upload failed for any form I attempt to fill out using the SANA client. The patient record DOES get created, however. So some communication is happening but there is nothing in the moca queue and no actual forms. Am I missing a piece?


Peter Lazar

unread,
Dec 14, 2012, 12:57:38 PM12/14/12
to sana-users on behalf of Eric Winkler
Aaaah, thank you...this sheds some light on the matter. I actually found a second "unbuntu" in the process of enabling the logs. On filling out the "welcome" form and submitting, I see the following

+0.174s openmrs.py:294  Got result {"status":"FAIL","code":"unspecified","message":"Concept error: Concept Undefined: (SUBJECT SOUND, Audio media file for patient encounter)"}
+0.174s openmrs.py:300  Done with upload
+0.174s api.py:297  API: RESULT = False
+0.174s json.py:229  Failed to register procedure: sp.pk -> 4, Concept error: Concept Undefined: (SUBJECT SOUND, Audio media file for patient encounter)

I set up openmrs as per the setup document with both "Sound" and "Subject sound"(as an attempt to alleviate this error) as misc/complex/mediafilehandler concepts. Can this be a permissions issue?

Eric Winkler

unread,
Dec 14, 2012, 1:28:00 PM12/14/12
to sana-...@googlegroups.com
The concept definition matching is very specific with respect to the name and description field. Extra white space or captialization differences will cause a failure. Basically in the OpenMRS definitions that you had "SOUND" and "SUBJECT SOUND", etc. 

Which set up document are you looking at? Apologies if there is a typo in one of the instructions. Let me know which you were looking at and i will get any corrections made.
Best,
Eric 

Peter Lazar

unread,
Dec 14, 2012, 1:46:36 PM12/14/12
to sana-users on behalf of Eric Winkler
It is this one

http://sana.mit.edu/wiki/index.php?title=Configure_OpenMRS_for_Moca

The problem was a trailing space in the description and sound,picture and video need to be SUBJECT PICTURE, SUBJECT SOUND, SUBJECT VIDEO.

It also complains about the barcode concept

+0.182s openmrs.py:294  Got result {"status":"FAIL","code":"unspecified","message":"Concept error: Concept Undefined: (BARCODE TEST, Scan barcode)"}
+0.182s openmrs.py:300  Done with upload
+0.182s api.py:297  API: RESULT = False
+0.183s json.py:229  Failed to register procedure: sp.pk -> 4, Concept error: Concept Undefined: (BARCODE TEST, Scan barcode)

Is the default roll not configured to run with the example apps?

Eric Winkler

unread,
Dec 14, 2012, 1:52:00 PM12/14/12
to sana-...@googlegroups.com
Unfortunately we don't have the sample apps set to load automatically into OpenMRS. I realize it is an inconvenience but is on the TODO list. Thanks for the link. Will take a look and make any corrections.
Eric


On Friday, December 14, 2012 1:46:36 PM UTC-5, Poppasmurf wrote:
It is this one

http://sana.mit.edu/wiki/index.php?title=Configure_OpenMRS_for_Moca

The problem was a trailing space in the description and sound,picture and video need to be SUBJECT PICTURE, SUBJECT SOUND, SUBJECT VIDEO.

It also complains about the barcode concept

+0.182s openmrs.py:294  Got result {"status":"FAIL","code":"unspecified","message":"Concept error: Concept Undefined: (BARCODE TEST, Scan barcode)"}
+0.182s openmrs.py:300  Done with upload
+0.182s api.py:297  API: RESULT = False
+0.183s json.py:229  Failed to register procedure: sp.pk -> 4, Concept error: Concept Undefined: (BARCODE TEST, Scan barcode)

Is the default roll not configured to run with the example apps?

Peter Lazar

unread,
Dec 14, 2012, 2:09:47 PM12/14/12
to sana-users on behalf of Eric Winkler
Now.....glorious victory...I feel like I can finally say that as a form has finished uploading and appears in the moca queue!

I'm starting to get the hang of this. Now to figure out how to write a basic encounter form.

Eric Winkler

unread,
Dec 14, 2012, 2:17:16 PM12/14/12
to sana-...@googlegroups.com
Great. Here are a couple of useful links in case you had not found them already:


and an the recently added online validation tool:

http://demo.sana.csail.mit.edu/xml/


On Friday, December 14, 2012 2:09:47 PM UTC-5, Poppasmurf wrote:
Now.....glorious victory...I feel like I can finally say that as a form has finished uploading and appears in the moca queue!

I'm starting to get the hang of this. Now to figure out how to write a basic encounter form.

Peter Lazar

unread,
Dec 17, 2012, 3:31:05 PM12/17/12
to sana-users on behalf of Eric Winkler
I just grabbed the source for the Sana App and compiled in a new form and graphics but noticed that the app felt different. Would this new difference cause it not to be able to talk with the 1.6 openmrs/mds stack?

Peter Lazar

unread,
Dec 17, 2012, 3:32:11 PM12/17/12
to sana-users on behalf of Eric Winkler
I am not seeing any traffic on the mds log at all despite using identical address and accounts as my previous instance.

Eric Winkler

unread,
Dec 17, 2012, 4:06:38 PM12/17/12
to sana-...@googlegroups.com
Regarding your questions:

I am not seeing any traffic on the mds log at all despite using identical address and accounts as my previous instance.
This may be a bit simplistic but did your MDS Url in the client settings get reset to the default 'demo.sana.csail.mit.edu'? There was some traffic on the server today.
 
I just grabbed the source for the Sana App and compiled in a new form and graphics but noticed that the app felt different. Would this new difference cause it not to be able to talk with the 1.6 openmrs/mds stack?
Could you give a bit more information about what you mean by felt a bit different? Also which version of the code did you grab? Neither the graphics nor updated procedure should have affected the upload.

Best,
Eric

Peter Lazar

unread,
Dec 17, 2012, 5:12:51 PM12/17/12
to sana-users on behalf of Eric Winkler
I actually hard coded our mds server into the client before exporting the apk file. I also changed the background graphic and the logo ( minor changes ) in the default settings, I commented out all of the forms and added a line for a basic form that I created (5-6 text fields for vitals), validated by the online XML validator. The client can seem to get a patient list added from the official client hosted off the demo server but cannot create any new entries. It simply states "not uploaded" and the mds log is eerily silent. 

I say the client is different due to the layout. The original version had three buttons stacked vertically and the "new" client has 5, 2 side by side with 3 below and it seems to have a bit higher resolution.



Eric Winkler

unread,
Dec 17, 2012, 6:22:43 PM12/17/12
to sana-...@googlegroups.com
Odd. There are a couple of pieces of information that might help track down the problem:

1. Branch of the code you were working with.
2. Device API level
3. Build API level

Other than that, it will probably help if you can send a copy of the log dump from the device. The debug level logs can potentially spew out some sensitive information so you may want to edit or you can send them directly to at sana.dev...@gmail.com so that you don't have to post them to the public forum.

Best,
Eric
Sana Development

Peter Lazar

unread,
Dec 18, 2012, 9:04:16 AM12/18/12
to sana-users on behalf of Eric Winkler
I am compiling branch "sana-release-1.1.x", using device api level 17 (Nexus 7 android 4.2, 512mb ram, 1gb disk), build is 4/"donut"/1.6 based on the target it was looking for.

Where does the log dump for the device exist? I am running it through the emulator directly...looks like I need to set up ADB.

Peter Lazar

unread,
Dec 18, 2012, 1:06:53 PM12/18/12
to sana-users on behalf of Eric Winkler
Well this is embarassing. I started up the android emulator from within eclipse for debugging purposes and gave the apache/tomcat services a healthy restart and it worked.

It seems like once it has failed to upload, it will not succeed until I restart the emulator. It says username/password incorrect but after restart, it succeeds without change.

Is the MDS server supposed to have the leading http:// ? That is the only thing I changed

Eric Winkler

unread,
Dec 18, 2012, 3:18:04 PM12/18/12
to sana-...@googlegroups.com
The value you use in the mobile client settings should not include the scheme-e.g. for the demo server the "Mobile Dispatch Server URL"  should bedemo.sana.csail.mit.edu. The http:// or https:// will get added to the beginning automatically depending on whether the "Secure Transmission" setting is checked.

Regarding the uploads, if an upload fails due to an error on the server end-could be missing concept, etc, you will need to go back into the View Prior encounters screen, select the encounter and hit Menu --> Resend. The basic idea being that the client will attempt to resend if the connectivity goes in and out-i.e. request gets sent but no response-but will stop trying to resend if it gets a fail response from the server such that it can assume that something needs to be fixed. Basically there is no point in constantly trying to resend automatically while things are getting looked at on the server. Please post if you continue to have issues with the uploads.

Thota Madhu Sudhan Rao

unread,
Jan 26, 2013, 2:08:45 AM1/26/13
to sana-...@googlegroups.com
 Problem with configuring sana .Can you checkout this
https://groups.google.com/forum/?fromgroups=#!topic/sana-users/E8ChFyW_ZtY
Reply all
Reply to author
Forward
0 new messages